Skip to content

Commit 9df556e

Browse files
author
Jens Kürten
committed
Merge branch 'main' of github.com:cslab/functions-sdk-python into add-dev-server
2 parents adf56a2 + ac5d301 commit 9df556e

File tree

9 files changed

+391
-0
lines changed

9 files changed

+391
-0
lines changed

csfunctions/events/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
from pydantic import Field
44

55
from .dialog_data import DocumentReleaseDialogData, PartReleaseDialogData
6+
from .document_create_check import DocumentCreateCheckData, DocumentCreateCheckEvent
7+
from .document_modify_check import DocumentModifyCheckData, DocumentModifyCheckEvent
68
from .document_release import DocumentReleaseData, DocumentReleaseEvent
79
from .document_release_check import DocumentReleaseCheckData, DocumentReleaseCheckEvent
810
from .dummy import DummyEvent, DummyEventData
911
from .engineering_change_release import EngineeringChangeRelease, EngineeringChangeReleaseData
1012
from .engineering_change_release_check import EngineeringChangeReleaseCheck, EngineeringChangeReleaseCheckData
1113
from .field_value_calculation import FieldValueCalculationData, FieldValueCalculationEvent
14+
from .part_create_check import PartCreateCheckData, PartCreateCheckEvent
15+
from .part_modify_check import PartModifyCheckData, PartModifyCheckEvent
1216
from .part_release import PartReleaseData, PartReleaseEvent
1317
from .part_release_check import PartReleaseCheckData, PartReleaseCheckEvent
1418
from .workflow_task_trigger import WorkflowTaskTriggerEvent, WorkflowTaskTriggerEventData
@@ -24,6 +28,10 @@
2428
EngineeringChangeRelease,
2529
EngineeringChangeReleaseCheck,
2630
WorkflowTaskTriggerEvent,
31+
DocumentCreateCheckEvent,
32+
DocumentModifyCheckEvent,
33+
PartCreateCheckEvent,
34+
PartModifyCheckEvent,
2735
],
2836
Field(discriminator="name"),
2937
]
@@ -37,6 +45,10 @@
3745
EngineeringChangeReleaseData,
3846
EngineeringChangeReleaseCheckData,
3947
WorkflowTaskTriggerEventData,
48+
DocumentCreateCheckData,
49+
DocumentModifyCheckData,
50+
PartCreateCheckData,
51+
PartModifyCheckData,
4052
]
4153

4254
__all__ = [
@@ -60,4 +72,12 @@
6072
"WorkflowTaskTriggerEventData",
6173
"DocumentReleaseDialogData",
6274
"PartReleaseDialogData",
75+
"DocumentCreateCheckData",
76+
"DocumentCreateCheckEvent",
77+
"DocumentModifyCheckData",
78+
"DocumentModifyCheckEvent",
79+
"PartCreateCheckData",
80+
"PartCreateCheckEvent",
81+
"PartModifyCheckData",
82+
"PartModifyCheckEvent",
6383
]

csfunctions/events/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class EventNames(str, Enum):
1313
ENGINEERING_CHANGE_RELEASE_CHECK = "engineering_change_release_check"
1414
FIELD_VALUE_CALCULATION = "field_value_calculation"
1515
WORKFLOW_TASK_TRIGGER = "workflow_task_trigger"
16+
DOCUMENT_CREATE_CHECK = "document_create_check"
17+
DOCUMENT_MODIFY_CHECK = "document_modify_check"
18+
PART_CREATE_CHECK = "part_create_check"
19+
PART_MODIFY_CHECK = "part_modify_check"
1620

1721

1822
class BaseEvent(BaseModel):
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from typing import Literal
2+
3+
from pydantic import BaseModel, Field
4+
5+
from csfunctions.objects import Document, Part
6+
7+
from .base import BaseEvent, EventNames
8+
9+
10+
class DocumentCreateCheckData(BaseModel):
11+
documents: list[Document] = Field(..., description="List of documents that are about to be created")
12+
linked_parts: list[Part] = Field(..., description="List of parts that belong to the documents")
13+
14+
15+
class DocumentCreateCheckEvent(BaseEvent):
16+
name: Literal[EventNames.DOCUMENT_CREATE_CHECK] = EventNames.DOCUMENT_CREATE_CHECK
17+
data: DocumentCreateCheckData
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from typing import Literal
2+
3+
from pydantic import BaseModel, Field
4+
5+
from csfunctions.objects import Document, Part
6+
7+
from .base import BaseEvent, EventNames
8+
9+
10+
class DocumentModifyCheckData(BaseModel):
11+
documents: list[Document] = Field(..., description="List of documents that are about to be modified")
12+
linked_parts: list[Part] = Field(..., description="List of parts that belong to the documents")
13+
14+
15+
class DocumentModifyCheckEvent(BaseEvent):
16+
name: Literal[EventNames.DOCUMENT_MODIFY_CHECK] = EventNames.DOCUMENT_MODIFY_CHECK
17+
data: DocumentModifyCheckData
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from typing import Literal
2+
3+
from pydantic import BaseModel, Field
4+
5+
from csfunctions.objects import Document, Part
6+
7+
from .base import BaseEvent, EventNames
8+
9+
10+
class PartCreateCheckData(BaseModel):
11+
parts: list[Part] = Field(..., description="List of parts that are about to be created")
12+
linked_documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")
13+
14+
15+
class PartCreateCheckEvent(BaseEvent):
16+
name: Literal[EventNames.PART_CREATE_CHECK] = EventNames.PART_CREATE_CHECK
17+
data: PartCreateCheckData
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from typing import Literal
2+
3+
from pydantic import BaseModel, Field
4+
5+
from csfunctions.objects import Document, Part
6+
7+
from .base import BaseEvent, EventNames
8+
9+
10+
class PartModifyCheckData(BaseModel):
11+
parts: list[Part] = Field(..., description="List of parts that are about to be modified")
12+
linked_documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")
13+
14+
15+
class PartModifyCheckEvent(BaseEvent):
16+
name: Literal[EventNames.PART_MODIFY_CHECK] = EventNames.PART_MODIFY_CHECK
17+
data: PartModifyCheckData

docs/reference/events.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
Events always have a `name` and a `data` attribute. The contents of those attributes depend on the type of the event.
22

3+
4+
## DocumentCreateCheckEvent
5+
`csfunctions.events.DocumentCreateCheckEvent`
6+
7+
This event is fired when a user tries to create or copy a document. Raising an exception will prevent the creation.
8+
The event is triggered before any field calculations are performed.
9+
10+
**Supported actions:**
11+
12+
- [AbortAndShowErrorAction](actions.md#AbortAndShowErrorAction)
13+
14+
**DocumentCreateCheckEvent.name:** document_create_check
15+
16+
**DocumentCreateCheckEvent.data:**
17+
18+
|Attribute|Type|Description|
19+
|-|-|-|
20+
|documents| list[[Document](objects.md#document)]|List of documents that are about to be created.|
21+
|linked_parts| list[[Part](objects.md#part)]|List of parts that belong to the documents.|
22+
23+
## DocumentModifyCheckEvent
24+
`csfunctions.events.DocumentModifyCheckEvent`
25+
26+
This event is fired when a user tries to modify a document. Raising an exception will prevent the modification.
27+
The event is triggered before any field calculations are performed.
28+
29+
**Supported actions:**
30+
31+
- [AbortAndShowErrorAction](actions.md#AbortAndShowErrorAction)
32+
33+
**DocumentModifyCheckEvent.name:** document_modify_check
34+
35+
**DocumentModifyCheckEvent.data:**
36+
37+
|Attribute|Type|Description|
38+
|-|-|-|
39+
|documents| list[[Document](objects.md#document)]|List of documents that are about to be modified.|
40+
|linked_parts| list[[Part](objects.md#part)]|List of parts that belong to the documents.|
41+
42+
343
## DocumentReleaseCheckEvent
444
`csfunctions.events.DocumentReleaseCheckEvent`
545

@@ -86,6 +126,43 @@ This event is fired **after** an engineering change has been released. Raising a
86126
|documents| list[[Document](objects.md#document)]|List of included documents.|
87127
|parts| list[[Part](objects.md#part)]|List of included parts.|
88128

129+
## PartCreateCheckEvent
130+
`csfunctions.events.PartCreateCheckEvent`
131+
132+
This event is fired when a user tries to create or copy a part. Raising an exception will prevent the creation.
133+
The event is triggered before any field calculations are performed.
134+
135+
**Supported actions:**
136+
137+
- [AbortAndShowErrorAction](actions.md#AbortAndShowErrorAction)
138+
139+
**PartCreateCheckEvent.name:** part_create_check
140+
141+
**PartCreateCheckEvent.data:**
142+
143+
|Attribute|Type|Description|
144+
|-|-|-|
145+
|parts| list[[Part](objects.md#part)]|List of parts that are about to be created.|
146+
|linked_documents| list[[Document](objects.md#document)]|List of documents that are referenced by the parts.|
147+
148+
## PartModifyCheckEvent
149+
`csfunctions.events.PartModifyCheckEvent`
150+
151+
This event is fired when a user tries to modify a part. Raising an exception will prevent the modification.
152+
The event is triggered before any field calculations are performed.
153+
154+
**Supported actions:**
155+
156+
- [AbortAndShowErrorAction](actions.md#AbortAndShowErrorAction)
157+
158+
**PartModifyCheckEvent.name:** part_modify_check
159+
160+
**PartModifyCheckEvent.data:**
161+
162+
|Attribute|Type|Description|
163+
|-|-|-|
164+
|parts| list[[Part](objects.md#part)]|List of parts that are about to be modified.|
165+
|linked_documents| list[[Document](objects.md#document)]|List of documents that are referenced by the parts.|
89166

90167
## PartReleaseCheckEvent
91168
`csfunctions.events.PartReleaseCheckEvent`

docs/release_notes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### Version 0.9.0:
2+
- Feature: Added new "Create Check" and "Modify Check" events for Documents, Parts and Engineering Changes, which are triggered before an object is created or modified and allow the creation or modification to be aborted by returning an Action.
3+
4+
### Version 0.8.4:
5+
- Add MyPy support
6+
17
### Version 0.8.3:
28
- added the fields `short_name`, `application` and `remark` to Material
39

0 commit comments

Comments
 (0)