oarepo-runtime 2.0.0.dev13__py3-none-any.whl → 2.0.0.dev15__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.
- oarepo_runtime/__init__.py +1 -1
- oarepo_runtime/api.py +23 -0
- oarepo_runtime/services/config/components.py +1 -1
- oarepo_runtime/services/generators.py +77 -0
- oarepo_runtime/services/records/__init__.py +2 -2
- oarepo_runtime/services/records/links.py +16 -12
- {oarepo_runtime-2.0.0.dev13.dist-info → oarepo_runtime-2.0.0.dev15.dist-info}/METADATA +1 -1
- {oarepo_runtime-2.0.0.dev13.dist-info → oarepo_runtime-2.0.0.dev15.dist-info}/RECORD +11 -10
- {oarepo_runtime-2.0.0.dev13.dist-info → oarepo_runtime-2.0.0.dev15.dist-info}/WHEEL +0 -0
- {oarepo_runtime-2.0.0.dev13.dist-info → oarepo_runtime-2.0.0.dev15.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-2.0.0.dev13.dist-info → oarepo_runtime-2.0.0.dev15.dist-info}/licenses/LICENSE +0 -0
oarepo_runtime/__init__.py
CHANGED
oarepo_runtime/api.py
CHANGED
@@ -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."""
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (c) 2025 CESNET z.s.p.o.
|
3
3
|
#
|
4
|
-
# This file is a part of oarepo-runtime (see
|
4
|
+
# This file is a part of oarepo-runtime (see https://github.com/oarepo/oarepo-runtime).
|
5
5
|
#
|
6
6
|
# oarepo-runtime is free software; you can redistribute it and/or modify it
|
7
7
|
# under the terms of the MIT License; see LICENSE file for more details.
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2025 CESNET z.s.p.o.
|
3
|
+
#
|
4
|
+
# This file is a part of oarepo-runtime (see https://github.com/oarepo/oarepo-runtime).
|
5
|
+
#
|
6
|
+
# oarepo-runtime is free software; you can redistribute it and/or modify it
|
7
|
+
# under the terms of the MIT License; see LICENSE file for more details.
|
8
|
+
#
|
9
|
+
"""Typed invenio generators."""
|
10
|
+
|
11
|
+
from __future__ import annotations
|
12
|
+
|
13
|
+
from abc import abstractmethod
|
14
|
+
from typing import TYPE_CHECKING, Any, override
|
15
|
+
|
16
|
+
from invenio_records_permissions.generators import (
|
17
|
+
ConditionalGenerator as InvenioConditionalGenerator,
|
18
|
+
)
|
19
|
+
from invenio_records_permissions.generators import Generator as InvenioGenerator
|
20
|
+
|
21
|
+
if TYPE_CHECKING:
|
22
|
+
from collections.abc import Sequence
|
23
|
+
|
24
|
+
from flask_principal import Need
|
25
|
+
from invenio_records_resources.records.api import Record
|
26
|
+
from invenio_search.engine import dsl
|
27
|
+
|
28
|
+
|
29
|
+
class Generator(InvenioGenerator):
|
30
|
+
"""Custom generator for the service.
|
31
|
+
|
32
|
+
This class will be removed when invenio has proper type stubs.
|
33
|
+
"""
|
34
|
+
|
35
|
+
@override
|
36
|
+
def needs(self, **kwargs: Any) -> Sequence[Need]: # type: ignore[reportIncompatibleMethodOverride]
|
37
|
+
return super().needs(**kwargs) # type: ignore[no-any-return]
|
38
|
+
|
39
|
+
@override
|
40
|
+
def excludes(self, **kwargs: Any) -> Sequence[Need]: # type: ignore[reportIncompatibleMethodOverride]
|
41
|
+
return super().excludes(**kwargs) # type: ignore[no-any-return]
|
42
|
+
|
43
|
+
@override
|
44
|
+
def query_filter(self, **kwargs: Any) -> dsl.query.Query: # type: ignore[reportIncompatibleMethodOverride]
|
45
|
+
return super().query_filter(**kwargs) # type: ignore[no-any-return]
|
46
|
+
|
47
|
+
|
48
|
+
class ConditionalGenerator(InvenioConditionalGenerator):
|
49
|
+
"""Typed conditional generator.
|
50
|
+
|
51
|
+
This class will be removed when invenio has proper type stubs.
|
52
|
+
"""
|
53
|
+
|
54
|
+
def __init__(self, then_: Sequence[InvenioGenerator], else_: Sequence[InvenioGenerator]) -> None:
|
55
|
+
"""Initialize the conditional generator."""
|
56
|
+
super().__init__(then_=then_, else_=else_)
|
57
|
+
|
58
|
+
@abstractmethod
|
59
|
+
def _condition(self, **kwargs: Any) -> bool:
|
60
|
+
"""Condition to choose generators set."""
|
61
|
+
raise NotImplementedError # pragma: nocover
|
62
|
+
|
63
|
+
def _generators(self, record: Record, **kwargs: Any) -> Sequence[InvenioGenerator]:
|
64
|
+
"""Get the "then" or "else" generators."""
|
65
|
+
return super()._generators(record=record, **kwargs) # type: ignore[no-any-return]
|
66
|
+
|
67
|
+
@override
|
68
|
+
def needs(self, **kwargs: Any) -> Sequence[Need]: # type: ignore[override]
|
69
|
+
return super().needs(**kwargs) # type: ignore[no-any-return]
|
70
|
+
|
71
|
+
@override
|
72
|
+
def excludes(self, **kwargs: Any) -> Sequence[Need]: # type: ignore[override]
|
73
|
+
return super().excludes(**kwargs) # type: ignore[no-any-return]
|
74
|
+
|
75
|
+
@override
|
76
|
+
def query_filter(self, **kwargs: Any) -> dsl.query.Query: # type: ignore[reportIncompatibleMethodOverride]
|
77
|
+
return super().query_filter(**kwargs) # type: ignore[no-any-return]
|
@@ -11,21 +11,25 @@
|
|
11
11
|
|
12
12
|
from __future__ import annotations
|
13
13
|
|
14
|
-
from
|
14
|
+
from typing import Any
|
15
15
|
|
16
|
+
from invenio_records_resources.services.base.links import EndpointLink
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
|
19
|
+
def pagination_endpoint_links_html(endpoint: str, params: dict[str, Any] | None = None) -> dict[str, EndpointLink]:
|
20
|
+
"""Create pagination links (prev/self/next) from the same endpoint."""
|
19
21
|
return {
|
20
|
-
"prev_html":
|
21
|
-
|
22
|
-
when=lambda pagination,
|
23
|
-
vars=lambda pagination,
|
22
|
+
"prev_html": EndpointLink(
|
23
|
+
endpoint,
|
24
|
+
when=lambda pagination, _ctx: pagination.has_prev,
|
25
|
+
vars=lambda pagination, _vars: _vars["args"].update({"page": pagination.prev_page.page}),
|
26
|
+
params=params,
|
24
27
|
),
|
25
|
-
"self_html":
|
26
|
-
"next_html":
|
27
|
-
|
28
|
-
when=lambda pagination,
|
29
|
-
vars=lambda pagination,
|
28
|
+
"self_html": EndpointLink(endpoint, params=params),
|
29
|
+
"next_html": EndpointLink(
|
30
|
+
endpoint,
|
31
|
+
when=lambda pagination, _ctx: pagination.has_next,
|
32
|
+
vars=lambda pagination, _vars: _vars["args"].update({"page": pagination.next_page.page}),
|
33
|
+
params=params,
|
30
34
|
),
|
31
35
|
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
oarepo_runtime/__init__.py,sha256=
|
2
|
-
oarepo_runtime/api.py,sha256=
|
1
|
+
oarepo_runtime/__init__.py,sha256=sXlnMCaH8x_i22x4r5wDRGIY_5qWXveMP5l-ZQa6u8A,686
|
2
|
+
oarepo_runtime/api.py,sha256=7gPeRS66moT1lIedPRmuK0EnB8PpGO7iD5eRCQOty4U,12552
|
3
3
|
oarepo_runtime/config.py,sha256=RUEPFn_5bKp9Wb0OY-Fb3VK30m35vF5IsLjYaQHhP3g,3838
|
4
4
|
oarepo_runtime/ext.py,sha256=CtUb3tkXsJv7l7lDq9yOeP1rDKaPhM2ULMIwqoJrBKo,7887
|
5
5
|
oarepo_runtime/proxies.py,sha256=PXaRiBh5qs5-h8M81cJOgtqypFQcYUSjiSn2TLSujRw,648
|
@@ -16,21 +16,22 @@ oarepo_runtime/records/systemfields/publication_status.py,sha256=1g3VXNPh0FsiPCp
|
|
16
16
|
oarepo_runtime/resources/__init__.py,sha256=voynQULXoOEviADkbOpekMphZPTAz4IOTg5BF9xPwTM,453
|
17
17
|
oarepo_runtime/resources/config.py,sha256=hJewyZ2FlEm4TtYnQS9JsnKnA6hhtSbvo1PC24-7f7Y,980
|
18
18
|
oarepo_runtime/services/__init__.py,sha256=OGtBgEeaDTyk2RPDNXuKbU9_7egFBZr42SM0gN5FrF4,341
|
19
|
+
oarepo_runtime/services/generators.py,sha256=B_4GXzKS8RUDGVzR_EZOYSD2uAC7P-xpmoYxo_52BTw,2888
|
19
20
|
oarepo_runtime/services/results.py,sha256=fk-Enx_LwZLbw81yZ7CXVTku86vd3_fjprnb8l5sFHk,6657
|
20
21
|
oarepo_runtime/services/config/__init__.py,sha256=SX1kfIGk8HkohdLQrNpRQUTltksEyDcCa-kFXxrX4e8,711
|
21
|
-
oarepo_runtime/services/config/components.py,sha256=
|
22
|
+
oarepo_runtime/services/config/components.py,sha256=cyU-JeMzLuBL-9JkUKbUQuu527WAq0yptGs6806XSho,23039
|
22
23
|
oarepo_runtime/services/config/link_conditions.py,sha256=raqf4yaBNLqNYgBxVNblo8MRJneVIFkwVNW7IW3AVYI,4309
|
23
24
|
oarepo_runtime/services/config/permissions.py,sha256=9_706Yyz7X6IXhSaRBnkmGOr7c8kLnEXNkGZxxgNafE,4138
|
24
25
|
oarepo_runtime/services/facets/__init__.py,sha256=k39ZYt1dMVOW01QRSTgx3CfuTYwvEWmL0VYTR3huVsE,349
|
25
26
|
oarepo_runtime/services/facets/params.py,sha256=BxAmPmHlPs5ILQsKR98jZUFOWBSeiF454vOSIVIJj40,4697
|
26
|
-
oarepo_runtime/services/records/__init__.py,sha256=
|
27
|
-
oarepo_runtime/services/records/links.py,sha256=
|
27
|
+
oarepo_runtime/services/records/__init__.py,sha256=Mpohx3xEXTmoodTEHbCih6I97JIofgqa_bf_Ysq4e2g,446
|
28
|
+
oarepo_runtime/services/records/links.py,sha256=oTKE9HXByQWEy8J6vT4KGjneeM_16MStwlXXglnnQSo,1254
|
28
29
|
oarepo_runtime/services/records/mapping.py,sha256=y3oeToKEnaRYpMV3q2-2cXNzyzyL3XXGvY26BifybpE,1332
|
29
30
|
oarepo_runtime/services/schema/__init__.py,sha256=jgAPI_uKC6Ug4KQWnwQVg3-aNaw-eHja323AUFo5ELo,351
|
30
31
|
oarepo_runtime/services/schema/i18n.py,sha256=9D1zOQaPKAnYzejB0vO-m2BJYnam0N0Lrq4jID7twfE,3174
|
31
32
|
oarepo_runtime/services/schema/i18n_ui.py,sha256=DbusphhGDeaobTt4nuwNgKZ6Houlu4Sv3SuMGkdjRRY,3582
|
32
|
-
oarepo_runtime-2.0.0.
|
33
|
-
oarepo_runtime-2.0.0.
|
34
|
-
oarepo_runtime-2.0.0.
|
35
|
-
oarepo_runtime-2.0.0.
|
36
|
-
oarepo_runtime-2.0.0.
|
33
|
+
oarepo_runtime-2.0.0.dev15.dist-info/METADATA,sha256=s1cx7KYYgNHY5A9h-0NgzY3DdZTAMmj7qopV7ETTY-Q,4495
|
34
|
+
oarepo_runtime-2.0.0.dev15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
35
|
+
oarepo_runtime-2.0.0.dev15.dist-info/entry_points.txt,sha256=rOfs8R1oXFN_dLH9zAZ6ydkvr83mDajegc6NBIRsCMQ,318
|
36
|
+
oarepo_runtime-2.0.0.dev15.dist-info/licenses/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
37
|
+
oarepo_runtime-2.0.0.dev15.dist-info/RECORD,,
|
File without changes
|
{oarepo_runtime-2.0.0.dev13.dist-info → oarepo_runtime-2.0.0.dev15.dist-info}/entry_points.txt
RENAMED
File without changes
|
{oarepo_runtime-2.0.0.dev13.dist-info → oarepo_runtime-2.0.0.dev15.dist-info}/licenses/LICENSE
RENAMED
File without changes
|