oarepo-runtime 2.0.0.dev29__tar.gz → 2.0.0.dev30__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 (48) hide show
  1. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/PKG-INFO +1 -1
  2. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/__init__.py +1 -1
  3. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/api.py +30 -0
  4. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/resources/config.py +9 -1
  5. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/.gitignore +0 -0
  6. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/LICENSE +0 -0
  7. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/README.md +0 -0
  8. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/cli/__init__.py +0 -0
  9. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/cli/search.py +0 -0
  10. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/config.py +0 -0
  11. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/ext.py +0 -0
  12. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/info/__init__.py +0 -0
  13. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/info/views.py +0 -0
  14. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/proxies.py +0 -0
  15. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/py.typed +0 -0
  16. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/records/__init__.py +0 -0
  17. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/records/drafts.py +0 -0
  18. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/records/mapping.py +0 -0
  19. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/records/pid_providers.py +0 -0
  20. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/records/systemfields/__init__.py +0 -0
  21. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/records/systemfields/custom_fields.py +0 -0
  22. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/records/systemfields/mapping.py +0 -0
  23. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/records/systemfields/publication_status.py +0 -0
  24. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/records/systemfields/selectors.py +0 -0
  25. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/resources/__init__.py +0 -0
  26. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/__init__.py +0 -0
  27. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/config/__init__.py +0 -0
  28. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/config/components.py +0 -0
  29. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/config/link_conditions.py +0 -0
  30. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/config/permissions.py +0 -0
  31. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/facets/__init__.py +0 -0
  32. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/facets/base.py +0 -0
  33. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/facets/date.py +0 -0
  34. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/facets/nested_facet.py +0 -0
  35. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/facets/params.py +0 -0
  36. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/facets/utils.py +0 -0
  37. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/generators.py +0 -0
  38. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/records/__init__.py +0 -0
  39. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/records/custom_fields.py +0 -0
  40. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/records/links.py +0 -0
  41. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/records/mapping.py +0 -0
  42. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/results.py +0 -0
  43. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/schema/__init__.py +0 -0
  44. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/schema/i18n.py +0 -0
  45. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/schema/i18n_ui.py +0 -0
  46. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/services/schema/ui.py +0 -0
  47. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/oarepo_runtime/typing.py +0 -0
  48. {oarepo_runtime-2.0.0.dev29 → oarepo_runtime-2.0.0.dev30}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oarepo-runtime
3
- Version: 2.0.0.dev29
3
+ Version: 2.0.0.dev30
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Project-URL: Homepage, https://github.com/oarepo/oarepo-runtime
6
6
  License-Expression: MIT
@@ -19,6 +19,6 @@ from .api import Model
19
19
  from .ext import OARepoRuntime
20
20
  from .proxies import current_runtime
21
21
 
22
- __version__ = "2.0.0dev29"
22
+ __version__ = "2.0.0dev30"
23
23
 
24
24
  __all__ = ("Model", "OARepoRuntime", "__version__", "current_runtime")
@@ -24,6 +24,7 @@ if TYPE_CHECKING:
24
24
  from collections.abc import Mapping
25
25
 
26
26
  from flask_babel.speaklater import LazyString
27
+ from flask_resources.deserializers import DeserializerMixin
27
28
  from flask_resources.responses import ResponseHandler
28
29
  from flask_resources.serializers import BaseSerializer
29
30
  from invenio_drafts_resources.records.api import Draft
@@ -92,6 +93,26 @@ class Export:
92
93
  """Description of the export format, human readable."""
93
94
 
94
95
 
96
+ @dataclasses.dataclass
97
+ class Import:
98
+ """Configuration of an import format."""
99
+
100
+ code: str
101
+ """Code of the import format, used to identify the import format in the URL."""
102
+
103
+ name: LazyString
104
+ """Name of the import format, human readable."""
105
+
106
+ mimetype: str
107
+ """MIME type of the import format."""
108
+
109
+ deserializer: DeserializerMixin
110
+ """Deserializer used to deserialize the record into the import format."""
111
+
112
+ description: LazyString | None = None
113
+ """Description of the import format, human readable."""
114
+
115
+
95
116
  class Model[
96
117
  S: RecordService = RecordService,
97
118
  C: RecordServiceConfig = RecordServiceConfig,
@@ -131,6 +152,7 @@ class Model[
131
152
  records_alias_enabled: bool = True,
132
153
  model_metadata: ModelMetadata | None = None,
133
154
  features: Mapping[str, Any] | None = None,
155
+ imports: list[Import] | None = None,
134
156
  ):
135
157
  """Initialize the model configuration.
136
158
 
@@ -155,6 +177,8 @@ class Model[
155
177
  Such models will be searchable via the `/api/records` endpoint.
156
178
  :param model_metadata: Metadata of the model.
157
179
  :param features: Features of the model. Filled by the feature presets themselves during registration.
180
+ :param imports: List of import formats that can be used to import the record.
181
+ If not provided, no imports are available.
158
182
  """
159
183
  self._code = code
160
184
  self._name = name
@@ -176,6 +200,7 @@ class Model[
176
200
  self._resource = resource
177
201
  self._resource_config = resource_config
178
202
  self._exports = exports or []
203
+ self._imports = imports or []
179
204
  self._model_metadata = model_metadata
180
205
  self._features = features
181
206
 
@@ -358,3 +383,8 @@ class Model[
358
383
  def features(self) -> Mapping[str, Any] | None:
359
384
  """Get a mapping of features."""
360
385
  return self._features
386
+
387
+ @property
388
+ def imports(self) -> list[Import]:
389
+ """Get all importable request body parsers."""
390
+ return self._imports
@@ -13,13 +13,14 @@ from __future__ import annotations
13
13
 
14
14
  from typing import TYPE_CHECKING
15
15
 
16
+ from flask_resources import RequestBodyParser
16
17
  from flask_resources.responses import ResponseHandler
17
18
  from invenio_records_resources.resources.records.headers import etag_headers
18
19
 
19
20
  if TYPE_CHECKING:
20
21
  from collections.abc import Iterable
21
22
 
22
- from oarepo_runtime.api import Export
23
+ from oarepo_runtime.api import Export, Import
23
24
 
24
25
 
25
26
  def exports_to_response_handlers(
@@ -33,3 +34,10 @@ def exports_to_response_handlers(
33
34
  )
34
35
  for export in exports
35
36
  }
37
+
38
+
39
+ def imports_to_request_body_parsers(
40
+ imports: Iterable[Import],
41
+ ) -> dict[str, RequestBodyParser]:
42
+ """Convert imports to a dictionary of mimetype -> request body parsers."""
43
+ return {import_option.mimetype: RequestBodyParser(import_option.deserializer) for import_option in imports}