oarepo-runtime 2.0.0.dev5__py3-none-any.whl → 2.0.0.dev6__py3-none-any.whl

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.
@@ -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.0dev5"
22
+ __version__ = "2.0.0dev6"
23
23
 
24
24
  __all__ = ("Model", "OARepoRuntime", "__version__", "current_runtime")
oarepo_runtime/api.py CHANGED
@@ -21,6 +21,8 @@ from invenio_base.utils import obj_or_import_string
21
21
  from invenio_records_resources.proxies import current_service_registry
22
22
 
23
23
  if TYPE_CHECKING:
24
+ from collections.abc import Mapping
25
+
24
26
  from flask_babel.speaklater import LazyString
25
27
  from flask_resources.responses import ResponseHandler
26
28
  from flask_resources.serializers import BaseSerializer
@@ -28,7 +30,11 @@ if TYPE_CHECKING:
28
30
  from invenio_records_resources.records.api import RecordBase
29
31
  from invenio_records_resources.resources.records.config import RecordResourceConfig
30
32
  from invenio_records_resources.resources.records.resource import RecordResource
31
- from invenio_records_resources.services import RecordService, RecordServiceConfig
33
+ from invenio_records_resources.services import (
34
+ FileService,
35
+ RecordService,
36
+ RecordServiceConfig,
37
+ )
32
38
 
33
39
 
34
40
  @dataclasses.dataclass
@@ -79,22 +85,6 @@ class Model[
79
85
  variable.
80
86
  """
81
87
 
82
- code: str
83
- """Code of the model, used to identify the model"""
84
-
85
- name: str | LazyString
86
- """Name of the model, human readable."""
87
-
88
- version: str
89
- """Version of the model, should be a valid semantic version."""
90
-
91
- description: str | LazyString | None = None
92
- """Description of the model, human readable."""
93
-
94
- records_alias_enabled: bool = False
95
- """Whether the records alias is enabled for this model. Such models will be searchable
96
- via the `/api/records` endpoint."""
97
-
98
88
  def __init__( # noqa: PLR0913 more attributes as we are creating a config
99
89
  self,
100
90
  *,
@@ -103,12 +93,17 @@ class Model[
103
93
  version: str,
104
94
  service: str | S,
105
95
  resource_config: RC | str,
96
+ ui_model: Mapping[str, Any] | None = None,
106
97
  # params with default values
107
98
  service_config: C | None = None,
108
99
  description: str | LazyString | None = None,
109
100
  record: type[R] | None = None,
110
101
  draft: type[D] | None = None,
111
- resource: str | RR = "invenio_records_resources.resources.records.resource.RecordResource",
102
+ resource: (str | RR) = "invenio_records_resources.resources.records.resource.RecordResource",
103
+ file_service: FileService | None = None,
104
+ draft_file_service: FileService | None = None,
105
+ media_file_service: FileService | None = None,
106
+ media_draft_file_service: FileService | None = None,
112
107
  exports: list[Export] | None = None,
113
108
  records_alias_enabled: bool = True,
114
109
  ):
@@ -134,11 +129,17 @@ class Model[
134
129
  :param records_alias_enabled: Whether the records alias is enabled for this model.
135
130
  Such models will be searchable via the `/api/records` endpoint.
136
131
  """
137
- self.code = code
138
- self.name = name
139
- self.version = version
140
- self.description = description
141
- self.records_alias_enabled = records_alias_enabled
132
+ self._code = code
133
+ self._name = name
134
+ self._version = version
135
+ self._description = description
136
+ self._records_alias_enabled = records_alias_enabled
137
+ self._ui_model = ui_model or {}
138
+
139
+ self._file_service = file_service
140
+ self._draft_file_service = draft_file_service
141
+ self._media_file_service = media_file_service
142
+ self._media_draft_file_service = media_draft_file_service
142
143
 
143
144
  # lazy getters ...
144
145
  self._record = record
@@ -149,6 +150,40 @@ class Model[
149
150
  self._resource_config = resource_config
150
151
  self._exports = exports or []
151
152
 
153
+ @property
154
+ def code(self) -> str:
155
+ """Return the machine-understandable code of the model."""
156
+ return self._code
157
+
158
+ @property
159
+ def name(self) -> str | LazyString:
160
+ """Get the human-readable name of the model."""
161
+ return self._name
162
+
163
+ @property
164
+ def version(self) -> str:
165
+ """Get the model's version."""
166
+ return self._version
167
+
168
+ @property
169
+ def description(self) -> str | LazyString | None:
170
+ """Get the model's description."""
171
+ return self._description
172
+
173
+ @property
174
+ def records_alias_enabled(self) -> bool:
175
+ """Get the records alias enabled flag.
176
+
177
+ This switch determines whether the records alias (/api/records)
178
+ is enabled for this model and whether the model is indexed in global search.
179
+ """
180
+ return self._records_alias_enabled
181
+
182
+ @property
183
+ def ui_model(self) -> Mapping[str, Any]:
184
+ """Get the UI model."""
185
+ return self._ui_model
186
+
152
187
  @property
153
188
  def service(self) -> S:
154
189
  """Get the service."""
@@ -182,6 +217,26 @@ class Model[
182
217
  return None
183
218
  return self._draft
184
219
 
220
+ @property
221
+ def file_service(self) -> FileService | None:
222
+ """Get the file service."""
223
+ return self._file_service
224
+
225
+ @property
226
+ def draft_file_service(self) -> FileService | None:
227
+ """Get the draft file service."""
228
+ return self._draft_file_service
229
+
230
+ @property
231
+ def media_file_service(self) -> FileService | None:
232
+ """Get the media file service."""
233
+ return self._media_file_service
234
+
235
+ @property
236
+ def media_draft_file_service(self) -> FileService | None:
237
+ """Get the media draft file service."""
238
+ return self._media_draft_file_service
239
+
185
240
  @property
186
241
  def api_blueprint_name(self) -> str:
187
242
  """Get the API blueprint name for the model."""
@@ -32,7 +32,7 @@ log = logging.getLogger(__name__)
32
32
  class GroupedFacetsParam(FacetsParam):
33
33
  """Facet parameter class that supports grouping of facets."""
34
34
 
35
- def __init__(self, config: SearchOptions):
35
+ def __init__(self, config: type[SearchOptions]):
36
36
  """Initialize the facets parameter with the given config."""
37
37
  super().__init__(config)
38
38
  self._facets = {**config.facets}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oarepo-runtime
3
- Version: 2.0.0.dev5
3
+ Version: 2.0.0.dev6
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
@@ -1,5 +1,5 @@
1
- oarepo_runtime/__init__.py,sha256=1nCgSbvNvQVT0Ynpy_ygn15FJOE0XbYHkK2sAzt5bWA,685
2
- oarepo_runtime/api.py,sha256=yRgU_LKuH3dRvK-M4phly3h9DzNYItaFtgbjqjeMEdA,8627
1
+ oarepo_runtime/__init__.py,sha256=_r7NviuUWi_2RA8KG16wk_5RY4ZxJ_BZYkf6_8K0MUc,685
2
+ oarepo_runtime/api.py,sha256=P_y8b5AFES0ssv6x_GDg4MtD6TIfoNsOAVMMoiRM560,10330
3
3
  oarepo_runtime/config.py,sha256=RUEPFn_5bKp9Wb0OY-Fb3VK30m35vF5IsLjYaQHhP3g,3838
4
4
  oarepo_runtime/ext.py,sha256=AMb5pMnCSbqIpPyP99YUKlf9vopz_b2ZW-RnvfsEVlk,3254
5
5
  oarepo_runtime/proxies.py,sha256=PXaRiBh5qs5-h8M81cJOgtqypFQcYUSjiSn2TLSujRw,648
@@ -18,15 +18,15 @@ oarepo_runtime/services/config/__init__.py,sha256=SX1kfIGk8HkohdLQrNpRQUTltksEyD
18
18
  oarepo_runtime/services/config/link_conditions.py,sha256=raqf4yaBNLqNYgBxVNblo8MRJneVIFkwVNW7IW3AVYI,4309
19
19
  oarepo_runtime/services/config/permissions.py,sha256=x5k61LGnpXyJfXVoCTq2tTVTtPckmBcBtcBJx4UN9EA,3056
20
20
  oarepo_runtime/services/facets/__init__.py,sha256=k39ZYt1dMVOW01QRSTgx3CfuTYwvEWmL0VYTR3huVsE,349
21
- oarepo_runtime/services/facets/params.py,sha256=B8RssdAt8bWRzwcTc5ireFkJg-q22DDOAprk9uhIwL4,4691
21
+ oarepo_runtime/services/facets/params.py,sha256=BxAmPmHlPs5ILQsKR98jZUFOWBSeiF454vOSIVIJj40,4697
22
22
  oarepo_runtime/services/records/__init__.py,sha256=c0n4vcMcJhSUWsKz0iyV4TTlGG8oLlJp0YEN0QGCZ8U,428
23
23
  oarepo_runtime/services/records/links.py,sha256=lqvnXabquL4DqWV93cdUYNUVYHx7T5Q0EXXuWAHM33A,1078
24
24
  oarepo_runtime/services/records/mapping.py,sha256=y3oeToKEnaRYpMV3q2-2cXNzyzyL3XXGvY26BifybpE,1332
25
25
  oarepo_runtime/services/schema/__init__.py,sha256=jgAPI_uKC6Ug4KQWnwQVg3-aNaw-eHja323AUFo5ELo,351
26
26
  oarepo_runtime/services/schema/i18n.py,sha256=9D1zOQaPKAnYzejB0vO-m2BJYnam0N0Lrq4jID7twfE,3174
27
27
  oarepo_runtime/services/schema/i18n_ui.py,sha256=DbusphhGDeaobTt4nuwNgKZ6Houlu4Sv3SuMGkdjRRY,3582
28
- oarepo_runtime-2.0.0.dev5.dist-info/METADATA,sha256=w-FR66FJ2qaM2QLi3u5U5d4icH5AiJoxVULomc4a97U,4494
29
- oarepo_runtime-2.0.0.dev5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
30
- oarepo_runtime-2.0.0.dev5.dist-info/entry_points.txt,sha256=7HqK5jumIgDVJa7ifjPKizginfIm5_R_qUVKPf_Yq-c,145
31
- oarepo_runtime-2.0.0.dev5.dist-info/licenses/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
32
- oarepo_runtime-2.0.0.dev5.dist-info/RECORD,,
28
+ oarepo_runtime-2.0.0.dev6.dist-info/METADATA,sha256=C8GjGM-BySVIrhvdW5mon3uYAq0YcP6WNqdKC0-rFIg,4494
29
+ oarepo_runtime-2.0.0.dev6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
30
+ oarepo_runtime-2.0.0.dev6.dist-info/entry_points.txt,sha256=7HqK5jumIgDVJa7ifjPKizginfIm5_R_qUVKPf_Yq-c,145
31
+ oarepo_runtime-2.0.0.dev6.dist-info/licenses/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
32
+ oarepo_runtime-2.0.0.dev6.dist-info/RECORD,,