eoapi-cdk 11.4.1 → 11.6.0

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 (46) hide show
  1. package/.jsii +38 -23
  2. package/README.md +2 -0
  3. package/lib/bastion-host/index.js +1 -1
  4. package/lib/database/index.js +1 -1
  5. package/lib/ingestor-api/index.d.ts +4 -0
  6. package/lib/ingestor-api/index.js +8 -3
  7. package/lib/ingestor-api/runtime/Dockerfile +13 -9
  8. package/lib/ingestor-api/runtime/pyproject.toml +37 -0
  9. package/lib/ingestor-api/runtime/src/config.py +9 -0
  10. package/lib/ingestor-api/runtime/src/handler.py +27 -4
  11. package/lib/ingestor-api/runtime/src/ingestor.py +1 -1
  12. package/lib/ingestor-api/runtime/src/schemas.py +11 -19
  13. package/lib/ingestor-api/runtime/src/services.py +4 -2
  14. package/lib/ingestor-api/runtime/uv.lock +1313 -0
  15. package/lib/lambda-api-gateway/index.js +1 -1
  16. package/lib/lambda-api-gateway-private/index.js +1 -1
  17. package/lib/stac-api/index.js +2 -2
  18. package/lib/stac-api/runtime/README.md +36 -0
  19. package/lib/stac-api/runtime/pyproject.toml +2 -2
  20. package/lib/stac-api/runtime/src/stac_api/handler.py +82 -86
  21. package/lib/stac-api/runtime/uv.lock +206 -182
  22. package/lib/stac-auth-proxy/index.js +2 -2
  23. package/lib/stac-auth-proxy/runtime/pyproject.toml +2 -2
  24. package/lib/stac-auth-proxy/runtime/src/stac_auth_proxy_api/handler.py +25 -2
  25. package/lib/stac-auth-proxy/runtime/uv.lock +174 -248
  26. package/lib/stac-browser/index.js +1 -1
  27. package/lib/stac-loader/index.js +2 -2
  28. package/lib/stac-loader/runtime/Dockerfile +1 -0
  29. package/lib/stac-loader/runtime/src/stac_loader/handler.py +2 -25
  30. package/lib/stac-loader/runtime/uv.lock +251 -252
  31. package/lib/stactools-item-generator/index.js +1 -1
  32. package/lib/stactools-item-generator/runtime/uv.lock +79 -75
  33. package/lib/tipg-api/index.js +2 -2
  34. package/lib/tipg-api/runtime/pyproject.toml +1 -1
  35. package/lib/tipg-api/runtime/src/tipg_api/handler.py +85 -75
  36. package/lib/tipg-api/runtime/uv.lock +248 -243
  37. package/lib/titiler-pgstac-api/index.js +2 -2
  38. package/lib/titiler-pgstac-api/runtime/pyproject.toml +2 -2
  39. package/lib/titiler-pgstac-api/runtime/src/titiler_pgstac_api/handler.py +79 -50
  40. package/lib/titiler-pgstac-api/runtime/uv.lock +319 -280
  41. package/lib/utils/utils.py +49 -15
  42. package/package.json +4 -4
  43. package/pyproject.toml +4 -0
  44. package/uv.lock +475 -73
  45. package/lib/ingestor-api/runtime/dev_requirements.txt +0 -4
  46. package/lib/ingestor-api/runtime/requirements.txt +0 -10
@@ -1,9 +1,32 @@
1
- """
2
- Entrypoint for Lambda execution.
3
- """
1
+ """Entrypoint for Lambda execution."""
2
+
3
+ import asyncio
4
+ from typing import Any
4
5
 
5
6
  from mangum import Mangum
6
7
 
7
8
  from .main import app
8
9
 
9
- handler = Mangum(app, lifespan="off", api_gateway_base_path=app.root_path)
10
+
11
+ def _ensure_event_loop() -> asyncio.AbstractEventLoop:
12
+ """Return the current event loop, creating and installing one if needed."""
13
+ try:
14
+ return asyncio.get_running_loop()
15
+ except RuntimeError:
16
+ pass
17
+
18
+ try:
19
+ return asyncio.get_event_loop()
20
+ except RuntimeError:
21
+ loop = asyncio.new_event_loop()
22
+ asyncio.set_event_loop(loop)
23
+ return loop
24
+
25
+
26
+ _asgi_handler = Mangum(app, lifespan="off", api_gateway_base_path=app.root_path)
27
+
28
+
29
+ def handler(event: Any, context: Any) -> dict[str, Any]:
30
+ """Handle AWS Lambda events with a guaranteed current event loop."""
31
+ _ensure_event_loop()
32
+ return _asgi_handler(event, context)
@@ -42,7 +42,7 @@ def update_dynamodb(
42
42
  with table.batch_writer(overwrite_by_pkeys=["created_by", "id"]) as batch:
43
43
  for ingestion in ingestions:
44
44
  batch.put_item(
45
- Item=ingestion.copy(
45
+ Item=ingestion.model_copy(
46
46
  update={
47
47
  "status": status,
48
48
  "message": message,
@@ -3,17 +3,15 @@ import binascii
3
3
  import enum
4
4
  import json
5
5
  from datetime import datetime
6
- from typing import TYPE_CHECKING, Dict, List, Optional, Union
6
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
7
7
  from urllib.parse import urlparse
8
8
 
9
9
  from fastapi.encoders import jsonable_encoder
10
- from fastapi.exceptions import RequestValidationError
11
10
  from pydantic import (
12
11
  BaseModel,
13
12
  Json,
14
13
  PositiveInt,
15
14
  dataclasses,
16
- error_wrappers,
17
15
  field_validator,
18
16
  )
19
17
  from stac_pydantic import Collection, Item, shared
@@ -107,25 +105,19 @@ class Ingestion(BaseModel):
107
105
  class ListIngestionRequest:
108
106
  status: Status = Status.queued
109
107
  limit: Optional[PositiveInt] = None
110
- next: Optional[str] = None
111
-
112
- def __post_init_post_parse__(self) -> None:
113
- # https://github.com/tiangolo/fastapi/issues/1474#issuecomment-1049987786
114
- if self.next is None:
115
- return
108
+ next: Optional[Any] = None
116
109
 
110
+ @field_validator("next", mode="before")
111
+ @classmethod
112
+ def decode_next_token(cls, v: Optional[str]) -> Optional[Any]:
113
+ """Decode the base64-encoded JSON pagination token supplied as a query param."""
114
+ if v is None:
115
+ return None
117
116
  try:
118
- self.next = json.loads(base64.b64decode(self.next))
117
+ return json.loads(base64.b64decode(v))
119
118
  except (UnicodeDecodeError, binascii.Error) as e:
120
- raise RequestValidationError(
121
- [
122
- error_wrappers.ErrorWrapper(
123
- ValueError(
124
- "Unable to decode next token. Should be base64 encoded JSON"
125
- ),
126
- "query.next",
127
- )
128
- ]
119
+ raise ValueError(
120
+ "Unable to decode next token. Should be base64 encoded JSON"
129
121
  ) from e
130
122
 
131
123
 
@@ -1,7 +1,7 @@
1
1
  from typing import TYPE_CHECKING, List
2
2
 
3
3
  from boto3.dynamodb import conditions
4
- from pydantic import parse_obj_as
4
+ from pydantic import TypeAdapter
5
5
 
6
6
  from . import schemas
7
7
 
@@ -35,7 +35,9 @@ class Database:
35
35
  **{"ExclusiveStartKey": next} if next else {},
36
36
  )
37
37
  return {
38
- "items": parse_obj_as(List[schemas.Ingestion], response["Items"]),
38
+ "items": TypeAdapter(List[schemas.Ingestion]).validate_python(
39
+ response["Items"]
40
+ ),
39
41
  "next": response.get("LastEvaluatedKey"),
40
42
  }
41
43