oarepo-runtime 2.0.0.dev14__tar.gz → 2.0.0.dev16__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 (37) hide show
  1. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/PKG-INFO +1 -1
  2. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/__init__.py +1 -1
  3. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/api.py +23 -0
  4. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/ext.py +11 -0
  5. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/.gitignore +0 -0
  6. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/LICENSE +0 -0
  7. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/README.md +0 -0
  8. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/cli/__init__.py +0 -0
  9. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/cli/search.py +0 -0
  10. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/config.py +0 -0
  11. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/proxies.py +0 -0
  12. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/py.typed +0 -0
  13. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/records/__init__.py +0 -0
  14. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/records/drafts.py +0 -0
  15. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/records/mapping.py +0 -0
  16. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/records/pid_providers.py +0 -0
  17. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/records/systemfields/__init__.py +0 -0
  18. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/records/systemfields/mapping.py +0 -0
  19. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/records/systemfields/publication_status.py +0 -0
  20. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/resources/__init__.py +0 -0
  21. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/resources/config.py +0 -0
  22. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/__init__.py +0 -0
  23. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/config/__init__.py +0 -0
  24. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/config/components.py +0 -0
  25. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/config/link_conditions.py +0 -0
  26. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/config/permissions.py +0 -0
  27. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/facets/__init__.py +0 -0
  28. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/facets/params.py +0 -0
  29. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/generators.py +0 -0
  30. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/records/__init__.py +0 -0
  31. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/records/links.py +0 -0
  32. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/records/mapping.py +0 -0
  33. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/results.py +0 -0
  34. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/schema/__init__.py +0 -0
  35. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/schema/i18n.py +0 -0
  36. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/oarepo_runtime/services/schema/i18n_ui.py +0 -0
  37. {oarepo_runtime-2.0.0.dev14 → oarepo_runtime-2.0.0.dev16}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oarepo-runtime
3
- Version: 2.0.0.dev14
3
+ Version: 2.0.0.dev16
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.0dev14"
22
+ __version__ = "2.0.0dev16"
23
23
 
24
24
  __all__ = ("Model", "OARepoRuntime", "__version__", "current_runtime")
@@ -41,6 +41,21 @@ if TYPE_CHECKING:
41
41
  )
42
42
 
43
43
 
44
+ @dataclasses.dataclass
45
+ class ModelMetadata:
46
+ """Model metadata configuration.
47
+
48
+ ModeMetadata is used in oarepo-model to add metadata to the model's oarepo_model_arguments dict.
49
+ """
50
+
51
+ types: dict[str, Any]
52
+ """Dictionary of types passed from InvenioModelBuilder.type_registry"""
53
+ metadata_type: str | None = None
54
+ """Metadata type"""
55
+ record_type: str | None = None
56
+ """Record type"""
57
+
58
+
44
59
  @dataclasses.dataclass
45
60
  class Export:
46
61
  """Configuration of an export format.
@@ -110,6 +125,7 @@ class Model[
110
125
  media_draft_file_service: FileService | None = None,
111
126
  exports: list[Export] | None = None,
112
127
  records_alias_enabled: bool = True,
128
+ model_metadata: ModelMetadata | None = None,
113
129
  ):
114
130
  """Initialize the model configuration.
115
131
 
@@ -132,6 +148,7 @@ class Model[
132
148
  If not provided, no exports are available.
133
149
  :param records_alias_enabled: Whether the records alias is enabled for this model.
134
150
  Such models will be searchable via the `/api/records` endpoint.
151
+ :param model_metadata: Metadata of the model.
135
152
  """
136
153
  self._code = code
137
154
  self._name = name
@@ -153,6 +170,7 @@ class Model[
153
170
  self._resource = resource
154
171
  self._resource_config = resource_config
155
172
  self._exports = exports or []
173
+ self._model_metadata = model_metadata
156
174
 
157
175
  @property
158
176
  def code(self) -> str:
@@ -183,6 +201,11 @@ class Model[
183
201
  """
184
202
  return self._records_alias_enabled
185
203
 
204
+ @property
205
+ def model_metadata(self) -> ModelMetadata | None:
206
+ """Get the model metadata."""
207
+ return self._model_metadata
208
+
186
209
  @property
187
210
  def ui_model(self) -> Mapping[str, Any]:
188
211
  """Get the UI model."""
@@ -29,6 +29,7 @@ if TYPE_CHECKING: # pragma: no cover
29
29
  from flask import Flask
30
30
  from invenio_drafts_resources.records.api import Draft
31
31
  from invenio_records_resources.services.base.service import Service
32
+ from invenio_records_resources.services.files.service import FileService
32
33
  from invenio_records_resources.services.records import RecordService
33
34
 
34
35
  from .api import Model
@@ -170,6 +171,16 @@ class OARepoRuntime:
170
171
  raise ValueError("Need to pass a record instance, got None")
171
172
  return self.get_record_service_for_record_class(type(record))
172
173
 
174
+ def get_file_service_for_record(self, record: Any) -> FileService | None:
175
+ """Return the file service for the given record (draft or published)."""
176
+ model = self.models_by_record_class.get(type(record))
177
+ if not model:
178
+ raise KeyError(f"No model found for record class '{type(record).__name__}'.")
179
+ is_draft = getattr(record, "is_draft", False)
180
+ if is_draft:
181
+ return model.draft_file_service
182
+ return model.file_service
183
+
173
184
  def get_record_service_for_record_class(self, record_cls: type[RecordBase]) -> RecordService:
174
185
  """Retrieve the service associated with a given record class."""
175
186
  for t in record_cls.mro():