sfeos-helpers 6.10.0__tar.gz → 6.10.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/PKG-INFO +2 -2
  2. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/pyproject.toml +1 -1
  3. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/database/__init__.py +12 -1
  4. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/database/index.py +2 -1
  5. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/database/utils.py +63 -0
  6. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/search_engine/inserters.py +4 -2
  7. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/search_engine/selection/selectors.py +0 -1
  8. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/version.py +1 -1
  9. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/.gitignore +0 -0
  10. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/README.md +0 -0
  11. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/aggregation/README.md +0 -0
  12. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/aggregation/__init__.py +0 -0
  13. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/aggregation/client.py +0 -0
  14. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/aggregation/format.py +0 -0
  15. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/database/README.md +0 -0
  16. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/database/catalogs.py +0 -0
  17. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/database/datetime.py +0 -0
  18. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/database/document.py +0 -0
  19. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/database/mapping.py +0 -0
  20. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/database/query.py +0 -0
  21. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/filter/README.md +0 -0
  22. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/filter/__init__.py +0 -0
  23. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/filter/client.py +0 -0
  24. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/filter/cql2.py +0 -0
  25. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/filter/transform.py +0 -0
  26. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/mappings.py +0 -0
  27. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/models/patch.py +0 -0
  28. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/search_engine/__init__.py +0 -0
  29. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/search_engine/base.py +0 -0
  30. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/search_engine/factory.py +0 -0
  31. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/search_engine/index_operations.py +0 -0
  32. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/search_engine/managers.py +0 -0
  33. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/search_engine/selection/__init__.py +0 -0
  34. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/search_engine/selection/base.py +0 -0
  35. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/search_engine/selection/cache_manager.py +0 -0
  36. {sfeos_helpers-6.10.0 → sfeos_helpers-6.10.1}/stac_fastapi/sfeos_helpers/search_engine/selection/factory.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sfeos_helpers
3
- Version: 6.10.0
3
+ Version: 6.10.1
4
4
  Summary: Helper library for the Elasticsearch and Opensearch stac-fastapi backends.
5
5
  Project-URL: Homepage, https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch
6
6
  License: MIT
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Classifier: Programming Language :: Python :: 3.14
16
16
  Requires-Python: >=3.11
17
- Requires-Dist: stac-fastapi-core==6.10.0
17
+ Requires-Dist: stac-fastapi-core==6.10.1
18
18
  Description-Content-Type: text/markdown
19
19
 
20
20
  # sfeos-helpers
@@ -29,7 +29,7 @@ keywords = [
29
29
  ]
30
30
  dynamic = ["version"]
31
31
  dependencies = [
32
- "stac-fastapi.core==6.10.0",
32
+ "stac-fastapi.core==6.10.1",
33
33
  ]
34
34
 
35
35
  [project.urls]
@@ -60,7 +60,14 @@ from .query import (
60
60
  apply_intersects_filter_shared,
61
61
  populate_sort_shared,
62
62
  )
63
- from .utils import add_bbox_shape_to_collection, get_bool_env, validate_refresh
63
+ from .utils import (
64
+ ItemAlreadyExistsError,
65
+ add_bbox_shape_to_collection,
66
+ check_item_exists_in_alias,
67
+ check_item_exists_in_alias_sync,
68
+ get_bool_env,
69
+ validate_refresh,
70
+ )
64
71
 
65
72
  __all__ = [
66
73
  # Catalog operations
@@ -90,6 +97,10 @@ __all__ = [
90
97
  "validate_refresh",
91
98
  "get_bool_env",
92
99
  "add_bbox_shape_to_collection",
100
+ "check_item_exists_in_alias",
101
+ "check_item_exists_in_alias_sync",
102
+ # Errors
103
+ "ItemAlreadyExistsError",
93
104
  # Datetime utilities
94
105
  "return_date",
95
106
  "extract_date",
@@ -165,7 +165,8 @@ def filter_indexes_by_datetime(
165
165
  datetime_alias if use_datetime else start_datetime_alias
166
166
  )
167
167
 
168
- filtered_indexes.append(primary_datetime_alias)
168
+ if primary_datetime_alias is not None:
169
+ filtered_indexes.append(primary_datetime_alias)
169
170
 
170
171
  return filtered_indexes
171
172
 
@@ -14,10 +14,73 @@ from stac_fastapi.extensions.core.transaction.request import (
14
14
  PatchRemove,
15
15
  )
16
16
  from stac_fastapi.sfeos_helpers.models.patch import ElasticPath, ESCommandSet
17
+ from stac_fastapi.types.errors import ConflictError
17
18
 
18
19
  logger = logging.getLogger(__name__)
19
20
 
20
21
 
22
+ class ItemAlreadyExistsError(ConflictError):
23
+ """Error raised when attempting to create an item that already exists.
24
+
25
+ Attributes:
26
+ item_id: The ID of the item that already exists.
27
+ collection_id: The ID of the collection containing the item.
28
+ """
29
+
30
+ def __init__(self, item_id: str, collection_id: str):
31
+ """Initialize the error with item and collection IDs."""
32
+ self.item_id = item_id
33
+ self.collection_id = collection_id
34
+ message = f"Item {item_id} in collection {collection_id} already exists"
35
+ super().__init__(message)
36
+
37
+
38
+ async def check_item_exists_in_alias(client: Any, alias: str, doc_id: str) -> bool:
39
+ """Check if an item exists across all indexes for an alias.
40
+
41
+ Args:
42
+ client: The async Elasticsearch/OpenSearch client.
43
+ alias: The index alias to search against.
44
+ doc_id: The document ID to check for existence.
45
+
46
+ Returns:
47
+ bool: True if the item exists in any index under the alias, False otherwise.
48
+ """
49
+ resp = await client.search(
50
+ index=alias,
51
+ body={
52
+ "query": {"ids": {"values": [doc_id]}},
53
+ "_source": False,
54
+ },
55
+ size=0,
56
+ terminate_after=1,
57
+ )
58
+ return bool(resp["hits"]["total"]["value"])
59
+
60
+
61
+ def check_item_exists_in_alias_sync(client: Any, alias: str, doc_id: str) -> bool:
62
+ """Check if an item exists across all indexes for an alias (sync).
63
+
64
+ Args:
65
+ client: The sync Elasticsearch/OpenSearch client.
66
+ alias: The index alias to search against.
67
+ doc_id: The document ID to check for existence.
68
+
69
+ Returns:
70
+ bool: True if the item exists in any index under the alias, False otherwise.
71
+ """
72
+ resp = client.search(
73
+ index=alias,
74
+ body={
75
+ "query": {"ids": {"values": [doc_id]}},
76
+ "_source": False,
77
+ },
78
+ size=0,
79
+ terminate_after=1,
80
+ )
81
+ return bool(resp["hits"]["total"]["value"])
82
+
83
+
21
84
  def add_bbox_shape_to_collection(collection: Dict[str, Any]) -> bool:
22
85
  """Add bbox_shape field to a collection document for spatial queries.
23
86
 
@@ -257,8 +257,10 @@ class DatetimeIndexInserter(BaseIndexInserter):
257
257
  extract_date(latest_item["_source"]["properties"]["datetime"])
258
258
  ),
259
259
  end_datetime=str(
260
- extract_date(latest_item["_source"]["properties"]["end_datetime"])
261
- ),
260
+ extract_first_date_from_index(aliases_dict["end_datetime"])
261
+ )
262
+ if aliases_dict.get("end_datetime")
263
+ else None,
262
264
  )
263
265
 
264
266
  await self.datetime_manager.handle_oversized_index(
@@ -1,5 +1,4 @@
1
1
  """Async index selectors with datetime-based filtering."""
2
-
3
2
  from typing import Any, Dict, List, Optional, Tuple
4
3
 
5
4
  from stac_fastapi.core.utilities import get_bool_env
@@ -1,2 +1,2 @@
1
1
  """library version."""
2
- __version__ = "6.10.0"
2
+ __version__ = "6.10.1"
File without changes