dsw-models 4.27.0__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.
@@ -0,0 +1,230 @@
1
+ import typing
2
+ from uuid import UUID
3
+
4
+ import pydantic
5
+
6
+ from .common import (
7
+ BaseModel,
8
+ MetricMeasure,
9
+ QuestionValidation,
10
+ TAnnotations,
11
+ THeaders,
12
+ TQuestionValueType,
13
+ TypeHintExchange,
14
+ )
15
+
16
+
17
+ class BaseKMFlatEntity(BaseModel):
18
+ uuid: UUID
19
+ annotations: TAnnotations
20
+
21
+
22
+ class Answer(BaseKMFlatEntity):
23
+ label: str
24
+ advice: str | None
25
+ metric_measures: list[MetricMeasure]
26
+ follow_up_uuids: list[UUID]
27
+
28
+
29
+ class Chapter(BaseKMFlatEntity):
30
+ title: str
31
+ text: str | None
32
+ question_uuids: list[UUID]
33
+
34
+
35
+ class Choice(BaseKMFlatEntity):
36
+ label: str
37
+
38
+
39
+ class Expert(BaseKMFlatEntity):
40
+ name: str
41
+ email: str
42
+
43
+
44
+ class ApiIntegration(BaseKMFlatEntity):
45
+ integration_type: typing.Literal['ApiIntegration'] = 'ApiIntegration'
46
+ name: str
47
+ variables: list[str]
48
+ allow_custom_reply: bool
49
+ request_method: str
50
+ request_url: str
51
+ request_headers: THeaders
52
+ request_body: str | None
53
+ request_allow_empty_search: bool
54
+ response_list_field: str | None
55
+ response_item_template: str
56
+ response_item_template_for_selection: str | None
57
+ test_q: str
58
+ test_variables: dict[str, str]
59
+ test_response: TypeHintExchange | None
60
+
61
+
62
+ class ApiLegacyIntegration(BaseKMFlatEntity):
63
+ integration_type: typing.Literal['ApiLegacyIntegration'] = 'ApiLegacyIntegration'
64
+ id: str
65
+ name: str
66
+ variables: list[str]
67
+ logo: str | None
68
+ request_method: str
69
+ request_url: str
70
+ request_headers: THeaders
71
+ request_body: str | None
72
+ request_empty_search: bool
73
+ response_list_field: str | None
74
+ response_item_id: str | None
75
+ response_item_template: str | None
76
+ item_url: str | None
77
+
78
+
79
+ class WidgetIntegration(BaseKMFlatEntity):
80
+ integration_type: typing.Literal['WidgetIntegration'] = 'WidgetIntegration'
81
+ id: str
82
+ name: str
83
+ variables: list[str]
84
+ logo: str | None
85
+ widget_url: str
86
+ item_url: str | None
87
+
88
+
89
+ Integration = typing.Annotated[
90
+ ApiIntegration |
91
+ ApiLegacyIntegration |
92
+ WidgetIntegration,
93
+ pydantic.Field(discriminator='integration_type'),
94
+ ]
95
+
96
+
97
+ class Metric(BaseKMFlatEntity):
98
+ title: str
99
+ abbreviation: str | None
100
+ description: str | None
101
+
102
+
103
+ class Phase(BaseKMFlatEntity):
104
+ title: str
105
+ description: str | None
106
+
107
+
108
+ class QuestionBase(BaseKMFlatEntity):
109
+ title: str
110
+ text: str | None
111
+ required_phase_uuid: UUID | None
112
+ expert_uuids: list[UUID]
113
+ reference_uuids: list[UUID]
114
+ tag_uuids: list[UUID]
115
+
116
+
117
+ class OptionsQuestion(QuestionBase):
118
+ question_type: typing.Literal['OptionsQuestion'] = 'OptionsQuestion'
119
+ answer_uuids: list[UUID]
120
+
121
+
122
+ class MultiChoiceQuestion(QuestionBase):
123
+ question_type: typing.Literal['MultiChoiceQuestion'] = 'MultiChoiceQuestion'
124
+ choice_uuids: list[UUID]
125
+
126
+
127
+ class ListQuestion(QuestionBase):
128
+ question_type: typing.Literal['ListQuestion'] = 'ListQuestion'
129
+ item_template_question_uuids: list[UUID]
130
+
131
+
132
+ class ValueQuestion(QuestionBase):
133
+ question_type: typing.Literal['ValueQuestion'] = 'ValueQuestion'
134
+ value_type: TQuestionValueType
135
+ validations: list[QuestionValidation]
136
+
137
+
138
+ class IntegrationQuestion(QuestionBase):
139
+ question_type: typing.Literal['IntegrationQuestion'] = 'IntegrationQuestion'
140
+ integration_uuid: UUID
141
+ variables: dict[str, str]
142
+
143
+
144
+ class ItemSelectQuestion(QuestionBase):
145
+ question_type: typing.Literal['ItemSelectQuestion'] = 'ItemSelectQuestion'
146
+ list_question_uuid: UUID
147
+
148
+
149
+ class FileQuestion(QuestionBase):
150
+ question_type: typing.Literal['FileQuestion'] = 'FileQuestion'
151
+ max_size: int
152
+ file_types: str | None
153
+
154
+
155
+ Question = typing.Annotated[
156
+ OptionsQuestion |
157
+ MultiChoiceQuestion |
158
+ ListQuestion |
159
+ ValueQuestion |
160
+ IntegrationQuestion |
161
+ ItemSelectQuestion |
162
+ FileQuestion,
163
+ pydantic.Field(discriminator='question_type'),
164
+ ]
165
+
166
+
167
+ class ResourcePageReference(BaseKMFlatEntity):
168
+ reference_type: typing.Literal['ResourcePageReference'] = 'ResourcePageReference'
169
+ resource_page_uuid: UUID
170
+
171
+
172
+ class URLReference(BaseKMFlatEntity):
173
+ reference_type: typing.Literal['URLReference'] = 'URLReference'
174
+ url: str
175
+ label: str
176
+
177
+
178
+ class CrossReference(BaseKMFlatEntity):
179
+ reference_type: typing.Literal['CrossReference'] = 'CrossReference'
180
+ target_uuid: UUID
181
+ description: str
182
+
183
+
184
+ Reference = typing.Annotated[
185
+ ResourcePageReference |
186
+ URLReference |
187
+ CrossReference,
188
+ pydantic.Field(discriminator='reference_type'),
189
+ ]
190
+
191
+
192
+ class ResourceCollection(BaseKMFlatEntity):
193
+ title: str
194
+ resource_page_uuids: list[UUID]
195
+
196
+
197
+ class ResourcePage(BaseKMFlatEntity):
198
+ title: str
199
+ content: str
200
+
201
+
202
+ class Tag(BaseKMFlatEntity):
203
+ name: str
204
+ description: str | None
205
+ color: str
206
+
207
+
208
+ class KnowledgeModelEntities(BaseModel):
209
+ answers: dict[UUID, Answer]
210
+ chapters: dict[UUID, Chapter]
211
+ choices: dict[UUID, Choice]
212
+ experts: dict[UUID, Expert]
213
+ integrations: dict[UUID, Integration]
214
+ metrics: dict[UUID, Metric]
215
+ phases: dict[UUID, Phase]
216
+ questions: dict[UUID, Question]
217
+ references: dict[UUID, Reference]
218
+ resource_collections: dict[UUID, ResourceCollection]
219
+ resource_pages: dict[UUID, ResourcePage]
220
+ tags: dict[UUID, Tag]
221
+
222
+
223
+ class KnowledgeModel(BaseKMFlatEntity):
224
+ entities: KnowledgeModelEntities
225
+ chapter_uuids: list[UUID]
226
+ integration_uuids: list[UUID]
227
+ metric_uuids: list[UUID]
228
+ phase_uuids: list[UUID]
229
+ resource_collection_uuids: list[UUID]
230
+ tag_uuids: list[UUID]
@@ -0,0 +1,34 @@
1
+ # pylint: disable=too-many-arguments, too-many-locals, too-many-lines
2
+ import datetime
3
+
4
+ from .common import BaseModel
5
+ from .events import Event
6
+
7
+
8
+ class KnowledgeModelPackage(BaseModel):
9
+ id: str
10
+ km_id: str
11
+ organization_id: str
12
+ version: str
13
+ name: str
14
+ metamodel_version: int
15
+ description: str
16
+ license: str
17
+ readme: str
18
+ created_at: datetime.datetime
19
+ fork_of_package_id: str | None
20
+ merge_checkpoint_package_id: str | None
21
+ previous_package_id: str | None
22
+ events: list[Event]
23
+ non_editable: bool = False
24
+ phase: str
25
+
26
+
27
+ class KnowledgeModelPackageBundle(BaseModel):
28
+ id: str
29
+ km_id: str
30
+ organization_id: str
31
+ version: str
32
+ metamodel_version: int
33
+ name: str
34
+ packages: list[KnowledgeModelPackage]
@@ -0,0 +1,177 @@
1
+ from uuid import UUID
2
+
3
+ import pydantic
4
+
5
+ from .common import (
6
+ BaseModel,
7
+ QuestionValidation,
8
+ TAnnotations,
9
+ TQuestionValueType,
10
+ TypeHintExchange,
11
+ )
12
+
13
+
14
+ class BaseKMTreeEntity(BaseModel):
15
+ uuid: UUID
16
+ annotations: TAnnotations
17
+
18
+
19
+ class MetricMeasure(BaseModel):
20
+ metric: 'Metric'
21
+ measure: float = pydantic.Field(ge=0.0, le=1.0)
22
+ weight: float = pydantic.Field(ge=0.0, le=1.0)
23
+
24
+
25
+ class Answer(BaseKMTreeEntity):
26
+ label: str
27
+ advice: str | None
28
+ metric_measures: list[MetricMeasure]
29
+ follow_ups: list['Question']
30
+
31
+
32
+ class Choice(BaseKMTreeEntity):
33
+ label: str
34
+
35
+
36
+ class Expert(BaseKMTreeEntity):
37
+ name: str
38
+ email: str
39
+
40
+
41
+ class Tag(BaseKMTreeEntity):
42
+ title: str
43
+ description: str | None
44
+ color: str
45
+
46
+
47
+ class Phase(BaseKMTreeEntity):
48
+ name: str
49
+ description: str | None
50
+
51
+
52
+ class Metric(BaseKMTreeEntity):
53
+ title: str
54
+ abbreviation: str | None
55
+ description: str | None
56
+
57
+
58
+ class ResourcePage(BaseKMTreeEntity):
59
+ title: str
60
+ content: str
61
+
62
+
63
+ class ResourceCollection(BaseKMTreeEntity):
64
+ title: str
65
+ resource_pages: list[ResourcePage]
66
+
67
+
68
+ class Integration(BaseKMTreeEntity):
69
+ name: str
70
+ variables: list[str]
71
+
72
+
73
+ class ApiIntegration(Integration):
74
+ allow_custom_reply: bool
75
+ request_method: str
76
+ request_url: str
77
+ request_body: str | None
78
+ request_allow_empty_search: bool
79
+ response_list_field: str
80
+ response_item_template: str
81
+ response_item_template_for_selection: str | None
82
+ test_q: str
83
+ test_variables: dict[str, str]
84
+ test_response: TypeHintExchange | None
85
+
86
+
87
+ class ApiLegacyIntegration(Integration):
88
+ id: str
89
+ logo: str | None
90
+ request_method: str
91
+ request_url: str
92
+ request_body: str | None
93
+ request_empty_search: bool
94
+ response_list_field: str | None
95
+ response_item_id: str | None
96
+ response_item_template: str | None
97
+ item_url: str | None
98
+
99
+
100
+ class WidgetIntegration(Integration):
101
+ id: str
102
+ logo: str | None
103
+ widget_url: str
104
+ item_url: str | None
105
+
106
+
107
+ class Reference(BaseKMTreeEntity):
108
+ pass
109
+
110
+
111
+ class ResourcePageReference(Reference):
112
+ resource_page: ResourcePage
113
+
114
+
115
+ class URLReference(Reference):
116
+ url: str
117
+ label: str
118
+
119
+
120
+ class CrossReference(Reference):
121
+ target: BaseKMTreeEntity
122
+ description: str
123
+
124
+
125
+ class Question(BaseKMTreeEntity):
126
+ title: str
127
+ text: str
128
+ required_phase: Phase | None
129
+ experts: list[Expert]
130
+ references: list[Reference]
131
+ tags: list[Tag]
132
+
133
+
134
+ class OptionsQuestion(Question):
135
+ answers: list[Answer]
136
+
137
+
138
+ class ChoiceQuestion(Question):
139
+ choices: list[Choice]
140
+
141
+
142
+ class ListQuestion(Question):
143
+ item_template_questions: list[Question]
144
+
145
+
146
+ class ValueQuestion(Question):
147
+ value_type: TQuestionValueType
148
+ validations: list[QuestionValidation]
149
+
150
+
151
+ class IntegrationQuestion(Question):
152
+ integration: Integration
153
+ variables: dict[str, str]
154
+
155
+
156
+ class ItemSelectQuestion(Question):
157
+ list_question: ListQuestion
158
+
159
+
160
+ class FileQuestion(Question):
161
+ max_size: int
162
+ file_types: str | None
163
+
164
+
165
+ class Chapter(BaseKMTreeEntity):
166
+ title: str
167
+ description: str
168
+ questions: list[Question]
169
+
170
+
171
+ class KnowledgeModel(BaseKMTreeEntity):
172
+ chapters: list[Chapter]
173
+ tags: list[Tag]
174
+ phases: list[Phase]
175
+ metrics: list[Metric]
176
+ integrations: list[Integration]
177
+ resource_collections: list[ResourceCollection]
File without changes
@@ -0,0 +1,14 @@
1
+ from uuid import UUID
2
+
3
+ from ..common import BaseModel
4
+
5
+
6
+ TODO_LABEL_UUID = UUID('615b9028-5e3f-414f-b245-12d2ae2eeb20')
7
+
8
+
9
+ class UserInfo(BaseModel):
10
+ uuid: UUID
11
+ first_name: str
12
+ last_name: str
13
+ gravatar_hash: str
14
+ image_url: str | None
@@ -0,0 +1,100 @@
1
+ import typing
2
+ from uuid import UUID, uuid4
3
+
4
+ import pydantic
5
+
6
+ from ..common import BaseModel
7
+ from .common import UserInfo
8
+ from .replies import ReplyValue
9
+
10
+
11
+ class BaseProjectEvent(BaseModel):
12
+ uuid: UUID = pydantic.Field(default_factory=uuid4)
13
+ type: str
14
+
15
+
16
+ class BaseProjectPathEvent(BaseProjectEvent):
17
+ path: str
18
+
19
+ @property
20
+ def path_parts(self) -> list[str]:
21
+ return self.path.split('.') if self.path else []
22
+
23
+
24
+ class SetPhaseEvent(BaseProjectEvent):
25
+ type: typing.Literal['SetPhaseEvent'] = 'SetPhaseEvent'
26
+ phase_uuid: UUID | None
27
+
28
+
29
+ class SetReplyEvent(BaseProjectPathEvent):
30
+ type: typing.Literal['SetReplyEvent'] = 'SetReplyEvent'
31
+ value: ReplyValue
32
+
33
+
34
+ class ClearReplyEvent(BaseProjectPathEvent):
35
+ type: typing.Literal['ClearReplyEvent'] = 'ClearReplyEvent'
36
+
37
+
38
+ class SetLabelsEvent(BaseProjectPathEvent):
39
+ type: typing.Literal['SetLabelsEvent'] = 'SetLabelsEvent'
40
+ labels: list[UUID]
41
+
42
+
43
+ class AddCommentEvent(BaseProjectPathEvent):
44
+ type: typing.Literal['AddCommentEvent'] = 'AddCommentEvent'
45
+ thread_uuid: UUID
46
+ comment_uuid: UUID
47
+ text: str
48
+ private: bool = False
49
+ new_thread: bool
50
+
51
+
52
+ class EditCommentEvent(BaseProjectPathEvent):
53
+ type: typing.Literal['EditCommentEvent'] = 'EditCommentEvent'
54
+ thread_uuid: UUID
55
+ comment_uuid: UUID
56
+ text: str
57
+ private: bool = False
58
+
59
+
60
+ class DeleteCommentEvent(BaseProjectPathEvent):
61
+ type: typing.Literal['DeleteCommentEvent'] = 'DeleteCommentEvent'
62
+ thread_uuid: UUID
63
+ comment_uuid: UUID
64
+ private: bool = False
65
+
66
+
67
+ class AssignCommentThreadEvent(BaseProjectPathEvent):
68
+ type: typing.Literal['AssignCommentThreadEvent'] = 'AssignCommentThreadEvent'
69
+ thread_uuid: UUID
70
+ private: bool = False
71
+ assigned_to: UserInfo | None
72
+
73
+
74
+ class ResolveCommentThreadEvent(BaseProjectPathEvent):
75
+ type: typing.Literal['ResolveCommentThreadEvent'] = 'ResolveCommentThreadEvent'
76
+ thread_uuid: UUID
77
+ private: bool = False
78
+ comment_count: int
79
+
80
+
81
+ class ReopenCommentThreadEvent(BaseProjectPathEvent):
82
+ type: typing.Literal['ReopenCommentThreadEvent'] = 'ReopenCommentThreadEvent'
83
+ thread_uuid: UUID
84
+ private: bool = False
85
+ comment_count: int
86
+
87
+
88
+ ProjectEvent = typing.Annotated[
89
+ SetPhaseEvent |
90
+ SetReplyEvent |
91
+ ClearReplyEvent |
92
+ SetLabelsEvent |
93
+ AddCommentEvent |
94
+ EditCommentEvent |
95
+ DeleteCommentEvent |
96
+ AssignCommentThreadEvent |
97
+ ResolveCommentThreadEvent |
98
+ ReopenCommentThreadEvent,
99
+ pydantic.Field(discriminator='type'),
100
+ ]
@@ -0,0 +1,15 @@
1
+ import datetime
2
+ from uuid import UUID
3
+
4
+ from ..common import BaseModel
5
+
6
+
7
+ class ProjectFile(BaseModel):
8
+ uuid: UUID
9
+ file_name: str
10
+ content_type: str
11
+ file_size: int
12
+ project_uuid: UUID
13
+ tenant_uuid: UUID
14
+ created_by: UUID | None
15
+ created_at: datetime.datetime
@@ -0,0 +1,94 @@
1
+ import datetime
2
+ import typing
3
+ from uuid import UUID
4
+
5
+ import pydantic
6
+
7
+ from ..common import BaseModel
8
+ from .common import UserInfo
9
+
10
+
11
+ class BaseIntegrationReplyType(BaseModel):
12
+ type: str
13
+
14
+
15
+ class PlainIntegrationReplyType(BaseIntegrationReplyType):
16
+ type: typing.Literal['PlainType'] = 'PlainType'
17
+ content: str
18
+
19
+
20
+ class IntegrationLegacyReplyType(BaseIntegrationReplyType):
21
+ type: typing.Literal['LegacyType'] = 'LegacyType'
22
+ id: str | None
23
+ value: str
24
+
25
+
26
+ class IntegrationReplyType(BaseModel):
27
+ type: typing.Literal['IntegrationType'] = 'IntegrationType'
28
+ value: str
29
+ raw: pydantic.Json[dict[str, typing.Any]]
30
+
31
+
32
+ IntegrationReply = typing.Annotated[
33
+ PlainIntegrationReplyType |
34
+ IntegrationLegacyReplyType |
35
+ IntegrationReplyType,
36
+ pydantic.Field(discriminator='type'),
37
+ ]
38
+
39
+
40
+ class BaseReplyValue(BaseModel):
41
+ type: str
42
+
43
+
44
+ class StringReplyValue(BaseReplyValue):
45
+ type: typing.Literal['StringReply'] = 'StringReply'
46
+ value: str
47
+
48
+
49
+ class AnswerReplyValue(BaseReplyValue):
50
+ type: typing.Literal['AnswerReply'] = 'AnswerReply'
51
+ value: UUID
52
+
53
+
54
+ class MultiChoiceReplyValue(BaseReplyValue):
55
+ type: typing.Literal['MultiChoiceReply'] = 'MultiChoiceReply'
56
+ value: list[UUID]
57
+
58
+
59
+ class ItemListReplyValue(BaseReplyValue):
60
+ type: typing.Literal['ItemListReply'] = 'ItemListReply'
61
+ value: list[str]
62
+
63
+
64
+ class IntegrationReplyValue(BaseReplyValue):
65
+ type: typing.Literal['IntegrationReply'] = 'IntegrationReply'
66
+ value: IntegrationReply
67
+
68
+
69
+ class ItemSelectionReplyValue(BaseReplyValue):
70
+ type: typing.Literal['ItemSelectReply'] = 'ItemSelectReply'
71
+ value: UUID
72
+
73
+
74
+ class FileReplyValue(BaseReplyValue):
75
+ type: typing.Literal['FileReply'] = 'FileReply'
76
+ value: UUID
77
+
78
+
79
+ ReplyValue = typing.Annotated[
80
+ StringReplyValue |
81
+ AnswerReplyValue |
82
+ MultiChoiceReplyValue |
83
+ ItemListReplyValue |
84
+ IntegrationReplyValue |
85
+ ItemSelectionReplyValue |
86
+ FileReplyValue,
87
+ pydantic.Field(discriminator='type'),
88
+ ]
89
+
90
+
91
+ class Reply(BaseModel):
92
+ value: ReplyValue
93
+ created_by: UserInfo | None
94
+ created_at: datetime.datetime
dsw/models/py.typed ADDED
File without changes
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.3
2
+ Name: dsw-models
3
+ Version: 4.27.0
4
+ Summary: Library with DSW models and basic IO operations
5
+ Keywords: dsw,config,yaml,parser
6
+ Author: Marek Suchánek
7
+ Author-email: Marek Suchánek <marek.suchanek@ds-wizard.org>
8
+ License: Apache License 2.0
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Topic :: Text Processing
16
+ Classifier: Topic :: Utilities
17
+ Requires-Dist: pydantic
18
+ Requires-Python: >=3.12, <4
19
+ Project-URL: Homepage, https://ds-wizard.org
20
+ Project-URL: Repository, https://github.com/ds-wizard/engine-tools
21
+ Project-URL: Documentation, https://guide.ds-wizard.org
22
+ Project-URL: Issues, https://github.com/ds-wizard/ds-wizard/issues
23
+ Description-Content-Type: text/markdown
24
+
25
+ # Data Stewardship Wizard: Models
26
+
27
+ [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/ds-wizard/engine-tools)](https://github.com/ds-wizard/engine-tools/releases)
28
+ [![PyPI](https://img.shields.io/pypi/v/dsw-config)](https://pypi.org/project/dsw-config/)
29
+ [![LICENSE](https://img.shields.io/github/license/ds-wizard/engine-tools)](LICENSE)
30
+ [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4975/badge)](https://bestpractices.coreinfrastructure.org/projects/4975)
31
+ [![Python Version](https://img.shields.io/badge/Python-%E2%89%A5%203.7-blue)](https://python.org)
32
+
33
+ *Library with DSW models and relevant transformations*
34
+
35
+ ## Usage
36
+
37
+ Currently, this library is intended for internal use of DSW tooling only.
38
+ Enhancements for use in custom scripts are planned for future development.
39
+
40
+ ## License
41
+
42
+ This project is licensed under the Apache License v2.0 - see the
43
+ [LICENSE](LICENSE) file for more details.