goodmap 2.0.0a7__tar.gz → 2.0.0a9__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 (28) hide show
  1. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/PKG-INFO +2 -2
  2. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/db.py +65 -0
  3. goodmap-2.0.0a9/goodmap/field_types.py +97 -0
  4. goodmap-2.0.0a9/goodmap/formatter.py +116 -0
  5. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/goodmap.py +23 -14
  6. goodmap-2.0.0a9/goodmap/initial_view.py +61 -0
  7. goodmap-2.0.0a9/goodmap/static/frontend/index.min.js +273 -0
  8. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/templates/map.html +1 -0
  9. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/pyproject.toml +2 -2
  10. goodmap-2.0.0a7/goodmap/formatter.py +0 -59
  11. goodmap-2.0.0a7/goodmap/static/frontend/index.min.js +0 -273
  12. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/LICENSE.md +0 -0
  13. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/README.md +0 -0
  14. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/__init__.py +0 -0
  15. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/api/admin_api.py +0 -0
  16. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/api/api_models.py +0 -0
  17. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/api/core_api.py +0 -0
  18. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/clustering.py +0 -0
  19. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/config.py +0 -0
  20. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/core.py +0 -0
  21. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/data_models/location.py +0 -0
  22. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/exceptions.py +0 -0
  23. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/feature_flags.py +0 -0
  24. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/filtering.py +0 -0
  25. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/json_security.py +0 -0
  26. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/marker_styles.py +0 -0
  27. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/plugin.py +0 -0
  28. {goodmap-2.0.0a7 → goodmap-2.0.0a9}/goodmap/templates/goodmap-admin.html +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: goodmap
3
- Version: 2.0.0a7
3
+ Version: 2.0.0a9
4
4
  Summary: Map engine to serve all the people :)
5
5
  Author: Krzysztof Kolodzinski
6
6
  Author-email: krzysztof.kolodzinski@problematy.pl
@@ -23,7 +23,7 @@ Requires-Dist: gunicorn (>=20.1,<26.0)
23
23
  Requires-Dist: humanize (>=4.6.0,<5.0.0)
24
24
  Requires-Dist: myst-parser (>=4.0.0,<5.0.0) ; extra == "docs"
25
25
  Requires-Dist: numpy (>=2.2.0,<3.0.0)
26
- Requires-Dist: platzky (==2.0.0a12)
26
+ Requires-Dist: platzky (==2.0.0a15)
27
27
  Requires-Dist: pydantic (>=2.12.0,<3.0.0)
28
28
  Requires-Dist: pysupercluster-problematy (>=0.7.8,<0.8.0)
29
29
  Requires-Dist: scipy (>=1.15.1,<2.0.0)
@@ -626,6 +626,70 @@ def get_marker_styles(db):
626
626
  return globals()[f"{db.module_name}_get_marker_styles"]
627
627
 
628
628
 
629
+ # ------------------------------------------------
630
+ # get_initial_view
631
+
632
+
633
+ def google_json_db_get_initial_view(self) -> dict[str, Any]:
634
+ """
635
+ Retrieve the map's opening view from Google Cloud Storage JSON blob.
636
+
637
+ Returns:
638
+ dict: Raw ``initial_view`` config (center, zoom). Returns empty dict if
639
+ not found - declaring a view is optional.
640
+ """
641
+ return self.data.get("map", {}).get("initial_view", {})
642
+
643
+
644
+ def json_file_db_get_initial_view(self) -> dict[str, Any]:
645
+ """
646
+ Retrieve the map's opening view from JSON file database.
647
+
648
+ Returns:
649
+ dict: Raw ``initial_view`` config (center, zoom). Returns empty dict if
650
+ not found - declaring a view is optional.
651
+ """
652
+ return self.data.get("map", {}).get("initial_view", {})
653
+
654
+
655
+ def json_db_get_initial_view(self) -> dict[str, Any]:
656
+ """
657
+ Retrieve the map's opening view from in-memory JSON database.
658
+
659
+ Returns:
660
+ dict: Raw ``initial_view`` config (center, zoom). Returns empty dict if
661
+ not found - declaring a view is optional.
662
+ """
663
+ return self.data.get("initial_view", {})
664
+
665
+
666
+ def mongodb_db_get_initial_view(self) -> dict[str, Any]:
667
+ """
668
+ Retrieve the map's opening view from MongoDB.
669
+
670
+ Returns:
671
+ dict: Raw ``initial_view`` config (center, zoom). Returns empty dict if
672
+ the config document is missing or does not declare one.
673
+ """
674
+ config_doc = self.db.config.find_one({"_id": "map_config"})
675
+ if config_doc:
676
+ return config_doc.get("initial_view", {})
677
+ return {}
678
+
679
+
680
+ def get_initial_view(db):
681
+ """
682
+ Get the appropriate get_initial_view function for the given database backend.
683
+
684
+ Args:
685
+ db: Database instance (must have module_name attribute).
686
+
687
+ Returns:
688
+ callable: Backend-specific get_initial_view function.
689
+ """
690
+ return globals()[f"{db.module_name}_get_initial_view"]
691
+
692
+
629
693
  # ------------------------------------------------
630
694
  # get_categories
631
695
 
@@ -1842,6 +1906,7 @@ def extend_db_with_goodmap_queries(db, location_model):
1842
1906
  db.extend("get_visible_data", get_visible_data(db))
1843
1907
  db.extend("get_meta_data", get_meta_data(db))
1844
1908
  db.extend("get_marker_styles", get_marker_styles(db))
1909
+ db.extend("get_initial_view", get_initial_view(db))
1845
1910
  db.extend("get_locations", get_locations(db, location_model))
1846
1911
  db.extend("get_locations_paginated", get_locations_paginated(db, location_model))
1847
1912
  db.extend("get_location", get_location(db, location_model))
@@ -0,0 +1,97 @@
1
+ """Goodmap's built-in marker field types.
2
+
3
+ A location entry names a field's ``type`` in the data - ``{"type": "hyperlink", "value": …}``
4
+ - and this module is the catalogue of the types goodmap ships. Each is an ordinary platzky
5
+ ``Shortcode``, the same thing a plugin contributes, so ``prepare_pin`` renders every field
6
+ through one interface and the popup gets ``html`` either way.
7
+
8
+ What differs is how a renderer is found. A plugin's shortcode is bound to a field by *name*,
9
+ which is what makes the field its own. Goodmap's own are looked up by the ``type`` the entry
10
+ declares, so any field can ask to be a ``hyperlink`` whatever it is called. That lookup is
11
+ safe only because this catalogue is closed: an entry may name a type in here and nothing
12
+ else, and so can never point itself at a plugin's renderer.
13
+ """
14
+
15
+ from collections.abc import Sequence
16
+ from urllib.parse import urlparse
17
+
18
+ from markupsafe import Markup, escape
19
+ from platzky.shortcodes import Shortcode, ShortcodeAttr, ShortcodeAttrs, UrlNotPermitted
20
+ from platzky.shortcodes.link import LinkShortcode
21
+
22
+ #: Schemes that navigate the browser somewhere, and so are worth a new tab.
23
+ _NEW_TAB_SCHEMES = frozenset({"http", "https"})
24
+
25
+
26
+ class HyperlinkFieldShortcode(LinkShortcode):
27
+ """A marker field holding a URL, rendered as a link.
28
+
29
+ Subclasses platzky's ``[link]`` rather than restating it, so a link in a post and a link
30
+ on a marker agree on what may be linked to - ``mailto:`` and ``tel:`` included, which is
31
+ how a place's contact details are routinely written - and produce the same anchor.
32
+
33
+ The field's own shape is declared rather than adapted to: ``value`` is where the link
34
+ goes, ``displayValue`` what it reads, and ``content_key`` makes the latter the inner
35
+ content so an absent one falls back to the URL, which ``render_value`` already does.
36
+ """
37
+
38
+ name = "hyperlink"
39
+ description = "A marker field holding a URL, shown as a link."
40
+ content_key = "displayValue"
41
+ attributes = ShortcodeAttrs(
42
+ [
43
+ ShortcodeAttr("value", "Where the link goes", required=True),
44
+ ShortcodeAttr("displayValue", "Text to show for it", required=False),
45
+ ]
46
+ )
47
+
48
+ def render(self, attrs: ShortcodeAttrs, content: str, children: Sequence[Markup]) -> str:
49
+ """Render the anchor, keeping the text when the URL is refused.
50
+
51
+ A refusal reaches ``render_value`` as a dropped element, which suits a link written
52
+ in prose but not a field: the label would be left sitting above a blank, the text is
53
+ usually the part a reader wanted, and a wrapper plugin attached to this type would
54
+ receive nothing to wrap. So it is caught here and the text kept, escaped and
55
+ unlinked.
56
+
57
+ Args:
58
+ attrs: The field's stored keys, ``value`` among them.
59
+ content: The link text, already escaped.
60
+ children: Element children, passed through to ``[link]``.
61
+
62
+ Returns:
63
+ An anchor, or just the link text when the URL is not one we may emit.
64
+ """
65
+ url = str(attrs.value or "")
66
+ # ``render_value`` falls back to ``value`` only when ``displayValue`` is absent; a
67
+ # present-but-empty one would otherwise render an anchor with nothing to click.
68
+ content = content or escape(url)
69
+ link_attrs = ShortcodeAttrs(list(LinkShortcode.attributes))
70
+ link_attrs.values = {"url": url}
71
+ # A new tab is for leaving the site; handing a mailto: or tel: to the mail client or
72
+ # dialer navigates nowhere, and asking for one anyway leaves a blank tab behind.
73
+ if urlparse(url).scheme in _NEW_TAB_SCHEMES:
74
+ link_attrs.values["target"] = "_blank"
75
+ try:
76
+ return super().render(link_attrs, content, children)
77
+ except UrlNotPermitted:
78
+ return str(content)
79
+
80
+
81
+ class CTAFieldShortcode(HyperlinkFieldShortcode):
82
+ """The same link, shown as a button below the details rather than among them.
83
+
84
+ ``hyperlink`` and ``CTA`` only ever differed in presentation - both are a URL and the
85
+ text to show for it - and where the popup puts one is ``LocationDetails``' business,
86
+ decided from the field name it already groups on. The ``type`` travels on the payload
87
+ either way, so a field plugin can still attach to just one of them.
88
+ """
89
+
90
+ name = "CTA"
91
+ description = "A marker field holding a URL, shown as a call-to-action button."
92
+
93
+
94
+ #: Field ``type`` -> the shortcode rendering it, keyed by the name written in the data.
95
+ BUILTIN_FIELD_TYPES: dict[str, Shortcode] = {
96
+ shortcode.name: shortcode for shortcode in (HyperlinkFieldShortcode(), CTAFieldShortcode())
97
+ }
@@ -0,0 +1,116 @@
1
+ """Formatters for translating and preparing location data for display."""
2
+
3
+ import logging
4
+ from typing import Any
5
+
6
+ from flask_babel import gettext, lazy_gettext
7
+
8
+ from goodmap.field_types import BUILTIN_FIELD_TYPES
9
+
10
+ logger = logging.getLogger(__name__)
11
+
12
+
13
+ def safe_gettext(text):
14
+ """Translate ``text``, mapping over a list and leaving a dict alone.
15
+
16
+ Args:
17
+ text: A str, a list of str, or a dict.
18
+
19
+ Returns:
20
+ The translation, in the same shape as the input.
21
+ """
22
+ if isinstance(text, list):
23
+ return list(map(gettext, text))
24
+ elif isinstance(text, dict):
25
+ return text
26
+ else:
27
+ return gettext(text)
28
+
29
+
30
+ def _builtin_shortcode(value):
31
+ """The built-in shortcode a field's own data asks for, if any.
32
+
33
+ Reached only where no plugin shortcode claimed the field by name, and only the closed
34
+ catalogue in :mod:`goodmap.field_types` is on offer - so an entry can never name its way
35
+ to a plugin's renderer.
36
+
37
+ Args:
38
+ value: The field's value from the location data.
39
+
40
+ Returns:
41
+ The Shortcode for the declared ``type``, or None when it names none goodmap ships.
42
+ """
43
+ if not isinstance(value, dict):
44
+ return None
45
+ field_type = value.get("type")
46
+ if not isinstance(field_type, str):
47
+ return None
48
+ return BUILTIN_FIELD_TYPES.get(field_type)
49
+
50
+
51
+ def _rendered_field(shortcode, value):
52
+ """Build the popup payload for a field, from whichever shortcode renders it.
53
+
54
+ The shortcode renders the value into ``html``, which is what lets goodmap's own types and
55
+ a plugin's alike display without shipping any frontend code. The entry's own keys travel
56
+ alongside for a React field plugin rendering from the data instead - a bare value under
57
+ the shortcode's ``content_key``, the name that plugin would look for. ``type`` is stamped
58
+ last, so an entry cannot redirect its own field at another renderer.
59
+
60
+ Because that bare value travels alongside, a shortcode's rendering is presentation, not
61
+ concealment: one that masks or drops part of what it displays still ships the original
62
+ here for anyone reading the response. Nothing in goodmap reads it - the popup needs only
63
+ ``html`` and ``type`` - so it is carried purely for a field plugin that would rather
64
+ render from the data, and could be dropped if none turns up wanting it.
65
+
66
+ Args:
67
+ shortcode: The Shortcode rendering this field.
68
+ value: The field's value from the location data.
69
+
70
+ Returns:
71
+ The field payload, carrying at least ``type`` and ``html``.
72
+ """
73
+ entry = value if isinstance(value, dict) else {shortcode.content_key: value}
74
+ return {**entry, "type": shortcode.name, "html": shortcode.render_value(value)}
75
+
76
+
77
+ def prepare_pin(place, visible_fields, meta_data, shortcodes=None) -> dict[str, Any]:
78
+ """Format one location into the translated payload its map popup renders.
79
+
80
+ Args:
81
+ place: The location's data.
82
+ visible_fields: Field names to show in the popup.
83
+ meta_data: Field names to carry as metadata.
84
+ shortcodes: Field name → the platzky Shortcode bound to it. A plugin claims a field
85
+ by name; anything else may still name a built-in ``type`` in its own data (see
86
+ :mod:`goodmap.field_types`). Either way one shortcode renders it.
87
+
88
+ Returns:
89
+ Title, subtitle, position, metadata, and ``data`` as ``[label, value]`` pairs.
90
+ """
91
+ plugins = shortcodes or {}
92
+ data = []
93
+ for field in visible_fields:
94
+ if field not in place:
95
+ continue
96
+ value = safe_gettext(place[field])
97
+ shortcode = plugins.get(field) or _builtin_shortcode(value)
98
+ if shortcode is not None:
99
+ value = _rendered_field(shortcode, value)
100
+ elif isinstance(value, dict) and "html" in value:
101
+ # ``html`` is this payload's word for "the server rendered this", and the popup
102
+ # injects it as markup. Nothing rendered this field, so an ``html`` here came
103
+ # from the data - a suggested point, an imported dataset - and must not be
104
+ # mistaken for goodmap's own output.
105
+ value = {key: item for key, item in value.items() if key != "html"}
106
+ data.append([gettext(field), value])
107
+ pin_data = {
108
+ "title": place["name"],
109
+ "subtitle": lazy_gettext(place["type_of_place"]), # TODO this should not be obligatory
110
+ "position": place["position"],
111
+ "metadata": {
112
+ gettext(field): safe_gettext(place[field]) for field in meta_data if field in place
113
+ },
114
+ "data": data,
115
+ }
116
+ return pin_data
@@ -10,8 +10,8 @@ from flask import Blueprint, jsonify, redirect, render_template, session
10
10
  from flask_wtf.csrf import CSRFError
11
11
  from platzky import platzky
12
12
  from platzky.config import languages_dict
13
+ from platzky.content_types import ContentType
13
14
  from platzky.models import CmsModule
14
- from platzky.plugin.content_transformer import ContentTransformerPluginBase
15
15
  from platzky.shortcodes import Shortcode
16
16
 
17
17
  from goodmap.api.admin_api import admin_pages
@@ -22,10 +22,12 @@ from goodmap.data_models.location import create_location_model
22
22
  from goodmap.db import (
23
23
  extend_db_with_goodmap_queries,
24
24
  get_category_data,
25
+ get_initial_view,
25
26
  get_location_obligatory_fields,
26
27
  get_marker_styles,
27
28
  )
28
29
  from goodmap.feature_flags import EnableAdminPanel
30
+ from goodmap.initial_view import resolve_initial_view
29
31
  from goodmap.marker_styles import resolve_marker_styles
30
32
  from goodmap.plugin import CAPABILITY_BASES, GoodmapPluginBase
31
33
 
@@ -33,6 +35,14 @@ logger = logging.getLogger(__name__)
33
35
 
34
36
  _PLUGIN_ENTRY_POINT_GROUP = "goodmap.plugins"
35
37
 
38
+
39
+ # A value stored against a map marker and shown in its popup: a kind of content platzky
40
+ # does not have, so goodmap names it and registers it. A plugin opts in through
41
+ # ``accepted_content_types`` and an operator grants it through ``allowed_content_types``,
42
+ # exactly as for a post — and by name, so neither has to import goodmap to handle one.
43
+ MARKER_FIELD_CONTENT_TYPE: ContentType = "marker_field"
44
+
45
+
36
46
  # Room above the attachment limit for a suggestion's text fields and multipart framing.
37
47
  MULTIPART_OVERHEAD_ALLOWANCE = 100 * 1024
38
48
 
@@ -150,6 +160,7 @@ def create_app_from_config(config: GoodmapConfig) -> platzky.Engine:
150
160
  config,
151
161
  extra_plugin_bases=list(CAPABILITY_BASES),
152
162
  extra_plugins_entrypoints=[_PLUGIN_ENTRY_POINT_GROUP],
163
+ extra_content_types=[MARKER_FIELD_CONTENT_TYPE],
153
164
  )
154
165
 
155
166
  frontend_static_dir = os.path.join(directory, "static", "frontend")
@@ -184,6 +195,11 @@ def create_app_from_config(config: GoodmapConfig) -> platzky.Engine:
184
195
  raw_marker_styles = get_marker_styles(app.db)(app.db)
185
196
  marker_styles = resolve_marker_styles(raw_marker_styles)
186
197
 
198
+ # Resolved once at startup rather than per request: the view cannot change without a
199
+ # restart, and resolving here is what makes a bad one fail the boot instead of every
200
+ # page load (see goodmap.initial_view).
201
+ initial_view = resolve_initial_view(get_initial_view(app.db)(app.db))
202
+
187
203
  location_model = create_location_model(location_obligatory_fields, categories)
188
204
  app.db = extend_db_with_goodmap_queries(app.db, location_model)
189
205
 
@@ -245,19 +261,11 @@ def create_app_from_config(config: GoodmapConfig) -> platzky.Engine:
245
261
 
246
262
  photo_attachment_config = config.attachment
247
263
 
248
- shortcodes: dict[str, Shortcode] = {}
249
- for plugin in app.loaded_plugins:
250
- if isinstance(plugin, ContentTransformerPluginBase):
251
- for name, sc in plugin.shortcodes.items():
252
- if name in shortcodes:
253
- logger.warning(
254
- "Shortcode '%s' from plugin '%s' conflicts with "
255
- "an already-registered shortcode; skipping",
256
- name,
257
- type(plugin).__name__,
258
- )
259
- else:
260
- shortcodes[name] = sc
264
+ # Only shortcodes whose plugin is both willing to handle marker fields and granted
265
+ # them by the operator. prepare_pin renders these through render_value, which does
266
+ # not pass through Engine.transform_content — collecting them off loaded_plugins
267
+ # instead would leave allowed_content_types governing posts but not popups.
268
+ shortcodes: dict[str, Shortcode] = app.shortcodes_for(MARKER_FIELD_CONTENT_TYPE)
261
269
 
262
270
  cp = core_pages(
263
271
  app.db,
@@ -291,6 +299,7 @@ def create_app_from_config(config: GoodmapConfig) -> platzky.Engine:
291
299
  goodmap_frontend_lib_url=config.goodmap_frontend_lib_url,
292
300
  plugin_manifest=plugin_manifest,
293
301
  marker_styles=marker_styles,
302
+ initial_view=initial_view,
294
303
  )
295
304
 
296
305
  @goodmap.route("/goodmap-admin")
@@ -0,0 +1,61 @@
1
+ """Validates a data source's ``initial_view`` into the view the browser opens on.
2
+
3
+ Runs once at startup (see goodmap.create_app_from_config), filling the optional
4
+ ``initial_view`` config out into the complete ``{center, zoom}`` the frontend is always
5
+ handed. A data source that says nothing gets the whole of Poland, which is what the frontend
6
+ hardcoded before this was configurable.
7
+
8
+ Validation is strict and uncaught by design: a nonsensical view - a latitude of 953, a zoom
9
+ no tile layer serves - stops the app from starting, so the mistake surfaces on deploy rather
10
+ than as a map that silently opens on the wrong continent.
11
+ """
12
+
13
+ from typing import Any, Mapping
14
+
15
+ from pydantic import BaseModel, ConfigDict, Field
16
+
17
+ from goodmap.data_models.location import Latitude, Longitude
18
+
19
+ # The frontend's tile layer is OpenStreetMap and nothing configures it away, so this is the
20
+ # furthest in any goodmap map can go - Leaflet clamps the map to its tile layer's ceiling.
21
+ # Bounding the opening zoom here is what stops a config asking for a view the tiles cannot
22
+ # serve and getting a silently clamped one instead. Kept in step by hand with
23
+ # frontend/src/components/Map/map.config.js, which tells the tile layer the same number.
24
+ MAX_TILE_ZOOM = 19
25
+
26
+ # The view the frontend opened on before this was configurable: the geographic centre of
27
+ # Poland, zoomed out far enough to hold the country.
28
+ DEFAULT_CENTER = (51.917, 19.013)
29
+ DEFAULT_ZOOM = 7
30
+
31
+
32
+ class InitialView(BaseModel):
33
+ """Where the map opens, as declared by a data source.
34
+
35
+ ``zoom`` is a Leaflet level - roughly 6 a country, 10 a province, 13 a town, 16 a street.
36
+ """
37
+
38
+ model_config = ConfigDict(frozen=True, extra="forbid")
39
+
40
+ center: tuple[Latitude, Longitude] = DEFAULT_CENTER
41
+ zoom: int = Field(default=DEFAULT_ZOOM, ge=0, le=MAX_TILE_ZOOM)
42
+
43
+
44
+ def resolve_initial_view(initial_view: Mapping[str, Any] | None) -> dict[str, Any]:
45
+ """The opening view the frontend needs, with every field filled in.
46
+
47
+ Args:
48
+ initial_view: The raw ``initial_view`` config. May be empty or None - declaring one
49
+ is optional.
50
+
51
+ Returns:
52
+ ``{"center": [lat, lng], "zoom": int}``, always complete, so the frontend carries no
53
+ defaults of its own. ``center`` is a list rather than a tuple because it is headed
54
+ for JSON either way.
55
+
56
+ Raises:
57
+ pydantic.ValidationError: A value is out of range or a key is unknown. Uncaught by
58
+ design - see the module docstring.
59
+ """
60
+ view = InitialView.model_validate(dict(initial_view or {}))
61
+ return {"center": list(view.center), "zoom": view.zoom}