oarepo-runtime 2.0.0.dev4__tar.gz → 2.0.0.dev6__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 (32) hide show
  1. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/PKG-INFO +1 -1
  2. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/__init__.py +1 -1
  3. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/api.py +94 -20
  4. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/config.py +13 -6
  5. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/facets/params.py +1 -1
  6. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/.gitignore +0 -0
  7. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/LICENSE +0 -0
  8. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/README.md +0 -0
  9. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/cli/__init__.py +0 -0
  10. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/cli/search.py +0 -0
  11. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/ext.py +0 -0
  12. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/proxies.py +0 -0
  13. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/records/__init__.py +0 -0
  14. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/records/drafts.py +0 -0
  15. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/records/mapping.py +0 -0
  16. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/records/pid_providers.py +0 -0
  17. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/records/systemfields/__init__.py +0 -0
  18. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/records/systemfields/mapping.py +0 -0
  19. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/records/systemfields/publication_status.py +0 -0
  20. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/__init__.py +0 -0
  21. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/config/__init__.py +0 -0
  22. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/config/link_conditions.py +0 -0
  23. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/config/permissions.py +0 -0
  24. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/facets/__init__.py +0 -0
  25. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/records/__init__.py +0 -0
  26. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/records/links.py +0 -0
  27. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/records/mapping.py +0 -0
  28. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/results.py +0 -0
  29. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/schema/__init__.py +0 -0
  30. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/schema/i18n.py +0 -0
  31. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/oarepo_runtime/services/schema/i18n_ui.py +0 -0
  32. {oarepo_runtime-2.0.0.dev4 → oarepo_runtime-2.0.0.dev6}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oarepo-runtime
3
- Version: 2.0.0.dev4
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
@@ -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.0dev4"
22
+ __version__ = "2.0.0dev6"
23
23
 
24
24
  __all__ = ("Model", "OARepoRuntime", "__version__", "current_runtime")
@@ -13,13 +13,16 @@ from __future__ import annotations
13
13
 
14
14
  import dataclasses
15
15
  from functools import cached_property
16
- from typing import TYPE_CHECKING, cast
16
+ from typing import TYPE_CHECKING, Any, cast
17
17
 
18
18
  from flask import current_app
19
+ from invenio_base import invenio_url_for
19
20
  from invenio_base.utils import obj_or_import_string
20
21
  from invenio_records_resources.proxies import current_service_registry
21
22
 
22
23
  if TYPE_CHECKING:
24
+ from collections.abc import Mapping
25
+
23
26
  from flask_babel.speaklater import LazyString
24
27
  from flask_resources.responses import ResponseHandler
25
28
  from flask_resources.serializers import BaseSerializer
@@ -27,7 +30,11 @@ if TYPE_CHECKING:
27
30
  from invenio_records_resources.records.api import RecordBase
28
31
  from invenio_records_resources.resources.records.config import RecordResourceConfig
29
32
  from invenio_records_resources.resources.records.resource import RecordResource
30
- from invenio_records_resources.services import RecordService, RecordServiceConfig
33
+ from invenio_records_resources.services import (
34
+ FileService,
35
+ RecordService,
36
+ RecordServiceConfig,
37
+ )
31
38
 
32
39
 
33
40
  @dataclasses.dataclass
@@ -37,6 +44,9 @@ class Export:
37
44
  Exports are shown on the record landing page and user can download them.
38
45
  """
39
46
 
47
+ code: str
48
+ """Code of the export format, used to identify the export format in the URL."""
49
+
40
50
  name: LazyString
41
51
  """Name of the export format, human readable."""
42
52
 
@@ -75,31 +85,25 @@ class Model[
75
85
  variable.
76
86
  """
77
87
 
78
- name: str | LazyString
79
- """Name of the model, human readable."""
80
-
81
- version: str
82
- """Version of the model, should be a valid semantic version."""
83
-
84
- description: str | LazyString | None = None
85
- """Description of the model, human readable."""
86
-
87
- records_alias_enabled: bool = False
88
- """Whether the records alias is enabled for this model. Such models will be searchable
89
- via the `/api/records` endpoint."""
90
-
91
88
  def __init__( # noqa: PLR0913 more attributes as we are creating a config
92
89
  self,
90
+ *,
91
+ code: str,
93
92
  name: str | LazyString,
94
93
  version: str,
95
94
  service: str | S,
96
95
  resource_config: RC | str,
96
+ ui_model: Mapping[str, Any] | None = None,
97
97
  # params with default values
98
98
  service_config: C | None = None,
99
99
  description: str | LazyString | None = None,
100
100
  record: type[R] | None = None,
101
101
  draft: type[D] | None = None,
102
- 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,
103
107
  exports: list[Export] | None = None,
104
108
  records_alias_enabled: bool = True,
105
109
  ):
@@ -125,10 +129,17 @@ class Model[
125
129
  :param records_alias_enabled: Whether the records alias is enabled for this model.
126
130
  Such models will be searchable via the `/api/records` endpoint.
127
131
  """
128
- self.name = name
129
- self.version = version
130
- self.description = description
131
- 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
132
143
 
133
144
  # lazy getters ...
134
145
  self._record = record
@@ -139,6 +150,40 @@ class Model[
139
150
  self._resource_config = resource_config
140
151
  self._exports = exports or []
141
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
+
142
187
  @property
143
188
  def service(self) -> S:
144
189
  """Get the service."""
@@ -172,6 +217,35 @@ class Model[
172
217
  return None
173
218
  return self._draft
174
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
+
240
+ @property
241
+ def api_blueprint_name(self) -> str:
242
+ """Get the API blueprint name for the model."""
243
+ return cast("str", self.resource_config.blueprint_name)
244
+
245
+ def api_url(self, view_name: str, **kwargs: Any) -> str:
246
+ """Get the API URL for the model."""
247
+ return cast("str", invenio_url_for(f"{self.api_blueprint_name}.{view_name}", **kwargs))
248
+
175
249
  @cached_property
176
250
  def resource_config(self) -> RC:
177
251
  """Get the resource configuration."""
@@ -13,6 +13,7 @@ from __future__ import annotations
13
13
 
14
14
  from typing import TYPE_CHECKING, Any
15
15
 
16
+ from invenio_i18n import lazy_gettext as _
16
17
  from invenio_vocabularies import __version__ as vocabularies_version
17
18
 
18
19
  from .api import Model
@@ -43,7 +44,8 @@ def build_config[T](config_class: type[T], app: Flask, *args: Any, **kwargs: Any
43
44
  OAREPO_MODELS: dict[str, Model] = {
44
45
  # default invenio vocabularies
45
46
  "vocabularies": Model(
46
- name="vocabularies",
47
+ code="vocabularies",
48
+ name=_("Base vocabularies"),
47
49
  version=vocabularies_version,
48
50
  service="vocabularies",
49
51
  description="Base (non-specialized) invenio vocabularies",
@@ -53,7 +55,8 @@ OAREPO_MODELS: dict[str, Model] = {
53
55
  ),
54
56
  # affiliations
55
57
  "affiliations": Model(
56
- name="affiliations",
58
+ code="affiliations",
59
+ name=_("Affiliations"),
57
60
  version=vocabularies_version,
58
61
  service="affiliations",
59
62
  description="Affiliations vocabulary",
@@ -63,7 +66,8 @@ OAREPO_MODELS: dict[str, Model] = {
63
66
  ),
64
67
  # funders
65
68
  "funders": Model(
66
- name="funders",
69
+ code="funders",
70
+ name=_("Funders"),
67
71
  version=vocabularies_version,
68
72
  service="funders",
69
73
  description="Funders vocabulary",
@@ -73,7 +77,8 @@ OAREPO_MODELS: dict[str, Model] = {
73
77
  ),
74
78
  # awards
75
79
  "awards": Model(
76
- name="awards",
80
+ code="awards",
81
+ name=_("Awards"),
77
82
  version=vocabularies_version,
78
83
  service="awards",
79
84
  description="Awards vocabulary",
@@ -83,7 +88,8 @@ OAREPO_MODELS: dict[str, Model] = {
83
88
  ),
84
89
  # names
85
90
  "names": Model(
86
- name="names",
91
+ code="names",
92
+ name=_("Names"),
87
93
  version=vocabularies_version,
88
94
  service="names",
89
95
  description="Names vocabulary",
@@ -93,7 +99,8 @@ OAREPO_MODELS: dict[str, Model] = {
93
99
  ),
94
100
  # subjects
95
101
  "subjects": Model(
96
- name="subjects",
102
+ code="subjects",
103
+ name=_("Subjects"),
97
104
  version=vocabularies_version,
98
105
  service="subjects",
99
106
  description="Subjects vocabulary",
@@ -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}