Skip to content

Commit 1bd1a3f

Browse files
jens-kuertenJens Kürtenclaude
authored
Feat: add part_blocked and document_blocked events (#49)
Add PartBlockedEvent and DocumentBlockedEvent, fired after a part or document has been blocked (status set to 170). Wire them into the event unions, exports, JSON schema and reference docs. Co-authored-by: Jens Kürten <jens.kuerten@contact-software.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c44dd1b commit 1bd1a3f

7 files changed

Lines changed: 194 additions & 4 deletions

File tree

csfunctions/events/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
CustomOperationPartEvent,
1919
)
2020
from .dialog_data import DocumentReleasedDialogData, PartReleasedDialogData
21+
from .document_blocked import DocumentBlockedData, DocumentBlockedEvent
2122
from .document_create_check import DocumentCreateCheckData, DocumentCreateCheckEvent
2223
from .document_field_calculation import DocumentFieldCalculationData, DocumentFieldCalculationEvent
2324
from .document_modify_check import DocumentModifyCheckData, DocumentModifyCheckEvent
@@ -32,6 +33,7 @@
3233
)
3334
from .engineering_change_status_changed import EngineeringChangeStatusChangedData, EngineeringChangeStatusChangedEvent
3435
from .field_value_calculation import FieldValueCalculationData, FieldValueCalculationEvent
36+
from .part_blocked import PartBlockedData, PartBlockedEvent
3537
from .part_create_check import PartCreateCheckData, PartCreateCheckEvent
3638
from .part_field_calculation import PartFieldCalculationData, PartFieldCalculationEvent
3739
from .part_modify_check import PartModifyCheckData, PartModifyCheckEvent
@@ -40,9 +42,11 @@
4042
from .workflow_task_trigger import WorkflowTaskTriggerEvent, WorkflowTaskTriggerEventData
4143

4244
Event = Annotated[
43-
DocumentReleasedEvent
45+
DocumentBlockedEvent
46+
| DocumentReleasedEvent
4447
| DocumentReleaseCheckEvent
4548
| DocumentFieldCalculationEvent
49+
| PartBlockedEvent
4650
| PartReleasedEvent
4751
| PartReleaseCheckEvent
4852
| PartFieldCalculationEvent
@@ -71,9 +75,11 @@
7175
Field(discriminator="name"),
7276
]
7377
EventData = (
74-
DocumentReleasedData
78+
DocumentBlockedData
79+
| DocumentReleasedData
7580
| DocumentReleaseCheckData
7681
| DocumentFieldCalculationData
82+
| PartBlockedData
7783
| PartReleasedData
7884
| PartReleaseCheckData
7985
| PartFieldCalculationData
@@ -102,9 +108,11 @@
102108
)
103109

104110
__all__ = [
111+
"DocumentBlockedEvent",
105112
"DocumentReleasedEvent",
106113
"DocumentReleaseCheckEvent",
107114
"DocumentFieldCalculationEvent",
115+
"PartBlockedEvent",
108116
"PartReleasedEvent",
109117
"PartReleaseCheckEvent",
110118
"PartFieldCalculationEvent",
@@ -124,9 +132,11 @@
124132
"ChangeRequestStatusChangedEvent",
125133
"ChangeRequestStatusChangeCheckEvent",
126134
"WorkflowTaskTriggerEvent",
135+
"DocumentBlockedData",
127136
"DocumentReleasedData",
128137
"DocumentReleaseCheckData",
129138
"DocumentFieldCalculationData",
139+
"PartBlockedData",
130140
"PartReleasedData",
131141
"PartReleaseCheckData",
132142
"BOMItemFieldCalculationData",

csfunctions/events/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55

66
class EventNames(str, Enum):
77
DUMMY = "dummy"
8+
DOCUMENT_BLOCKED = "document_blocked"
89
DOCUMENT_RELEASED = "document_released"
910
DOCUMENT_RELEASE_CHECK = "document_release_check"
1011
DOCUMENT_FIELD_CALCULATION = "document_field_calculation"
12+
PART_BLOCKED = "part_blocked"
1113
PART_RELEASED = "part_released"
1214
PART_RELEASE_CHECK = "part_release_check"
1315
PART_FIELD_CALCULATION = "part_field_calculation"
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 DocumentBlockedData(BaseModel):
11+
documents: list[Document] = Field(..., description="List of documents that were blocked.")
12+
parts: list[Part] = Field(..., description="List of parts that belong to the documents.")
13+
14+
15+
class DocumentBlockedEvent(BaseEvent):
16+
name: Literal[EventNames.DOCUMENT_BLOCKED] = EventNames.DOCUMENT_BLOCKED
17+
data: DocumentBlockedData

csfunctions/events/part_blocked.py

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 PartBlockedData(BaseModel):
11+
parts: list[Part] = Field(..., description="List of parts that were blocked.")
12+
documents: list[Document] = Field(..., description="List of documents that belong to the parts.")
13+
14+
15+
class PartBlockedEvent(BaseEvent):
16+
name: Literal[EventNames.PART_BLOCKED] = EventNames.PART_BLOCKED
17+
data: PartBlockedData

docs/reference/events.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,24 @@ This event is fired **after** a document has been released. Raising an exception
102102
| cdb_ec_id | str \| None | Engineering Change ID |
103103

104104

105+
## DocumentBlockedEvent
106+
`csfunctions.events.DocumentBlockedEvent`
107+
108+
This event is fired **after** a document has been blocked (status set to 170). Raising an exception thus can not prevent the blocking.
109+
110+
**Supported actions:**
111+
112+
- [StartWorkflowAction](actions.md#startworkflowaction)
113+
114+
**DocumentBlockedEvent.name:** document_blocked
115+
116+
**DocumentBlockedEvent.data:**
117+
118+
| Attribute | Type | Description |
119+
| --------- | ------------------------------------- | ------------------------------------------- |
120+
| documents | list[[Document](objects.md#document)] | List of documents that were blocked. |
121+
| parts | list[[Part](objects.md#part)] | List of parts that belong to the documents. |
122+
105123
## DocumentFieldCalculationEvent
106124
`csfunctions.events.DocumentFieldCalculationEvent`
107125

@@ -421,6 +439,24 @@ This event is fired **after** a part has been released. Raising an exception thu
421439
| cdb_ec_id | str \| None | Engineering Change ID |
422440

423441

442+
## PartBlockedEvent
443+
`csfunctions.events.PartBlockedEvent`
444+
445+
This event is fired **after** a part has been blocked (status set to 170). Raising an exception thus can not prevent the blocking.
446+
447+
**Supported actions:**
448+
449+
- [StartWorkflowAction](actions.md#startworkflowaction)
450+
451+
**PartBlockedEvent.name:** part_blocked
452+
453+
**PartBlockedEvent.data:**
454+
455+
| Attribute | Type | Description |
456+
| --------- | ------------------------------------- | ---------------------------------------- |
457+
| parts | list[[Part](objects.md#part)] | List of parts that were blocked. |
458+
| documents | list[[Document](objects.md#document)] | List of documents that belong to the parts. |
459+
424460
## PartFieldCalculationEvent
425461
`csfunctions.events.PartFieldCalculationEvent`
426462

docs/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ hide:
33
- toc
44
---
55

6-
### Version 0.27.0
7-
- Feat: Add reviewers field to PartReleaseCheckEvent and DocumentReleaseCheckEvent, populated for express releases
86

97
### Version 0.26.0
108
- Feat: Extend all multi-language object fields with Japanese (ja) and Chinese (zh) variants
9+
- Feat: Add part_blocked and document_blocked events
10+
- Feat: Add reviewers field to PartReleaseCheckEvent and DocumentReleaseCheckEvent, populated for express releases
1111

1212
### Version 0.25.0
1313
- Feat: Add change objects (ChangeOrder and ChangeRequest) with their release and status change events

json_schemas/request.json

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7235,6 +7235,56 @@
72357235
"title": "Document",
72367236
"type": "object"
72377237
},
7238+
"DocumentBlockedData": {
7239+
"properties": {
7240+
"documents": {
7241+
"description": "List of documents that were blocked.",
7242+
"items": {
7243+
"$ref": "#/$defs/Document"
7244+
},
7245+
"title": "Documents",
7246+
"type": "array"
7247+
},
7248+
"parts": {
7249+
"description": "List of parts that belong to the documents.",
7250+
"items": {
7251+
"$ref": "#/$defs/Part"
7252+
},
7253+
"title": "Parts",
7254+
"type": "array"
7255+
}
7256+
},
7257+
"required": [
7258+
"documents",
7259+
"parts"
7260+
],
7261+
"title": "DocumentBlockedData",
7262+
"type": "object"
7263+
},
7264+
"DocumentBlockedEvent": {
7265+
"properties": {
7266+
"name": {
7267+
"const": "document_blocked",
7268+
"default": "document_blocked",
7269+
"title": "Name",
7270+
"type": "string"
7271+
},
7272+
"event_id": {
7273+
"description": "unique identifier",
7274+
"title": "Event Id",
7275+
"type": "string"
7276+
},
7277+
"data": {
7278+
"$ref": "#/$defs/DocumentBlockedData"
7279+
}
7280+
},
7281+
"required": [
7282+
"event_id",
7283+
"data"
7284+
],
7285+
"title": "DocumentBlockedEvent",
7286+
"type": "object"
7287+
},
72387288
"DocumentCreateCheckData": {
72397289
"properties": {
72407290
"documents": {
@@ -10967,6 +11017,56 @@
1096711017
"title": "Part",
1096811018
"type": "object"
1096911019
},
11020+
"PartBlockedData": {
11021+
"properties": {
11022+
"parts": {
11023+
"description": "List of parts that were blocked.",
11024+
"items": {
11025+
"$ref": "#/$defs/Part"
11026+
},
11027+
"title": "Parts",
11028+
"type": "array"
11029+
},
11030+
"documents": {
11031+
"description": "List of documents that belong to the parts.",
11032+
"items": {
11033+
"$ref": "#/$defs/Document"
11034+
},
11035+
"title": "Documents",
11036+
"type": "array"
11037+
}
11038+
},
11039+
"required": [
11040+
"parts",
11041+
"documents"
11042+
],
11043+
"title": "PartBlockedData",
11044+
"type": "object"
11045+
},
11046+
"PartBlockedEvent": {
11047+
"properties": {
11048+
"name": {
11049+
"const": "part_blocked",
11050+
"default": "part_blocked",
11051+
"title": "Name",
11052+
"type": "string"
11053+
},
11054+
"event_id": {
11055+
"description": "unique identifier",
11056+
"title": "Event Id",
11057+
"type": "string"
11058+
},
11059+
"data": {
11060+
"$ref": "#/$defs/PartBlockedData"
11061+
}
11062+
},
11063+
"required": [
11064+
"event_id",
11065+
"data"
11066+
],
11067+
"title": "PartBlockedEvent",
11068+
"type": "object"
11069+
},
1097011070
"PartCreateCheckData": {
1097111071
"properties": {
1097211072
"parts": {
@@ -11513,6 +11613,7 @@
1151311613
"change_request_status_changed": "#/$defs/ChangeRequestStatusChangedEvent",
1151411614
"custom_operation_document": "#/$defs/CustomOperationDocumentEvent",
1151511615
"custom_operation_part": "#/$defs/CustomOperationPartEvent",
11616+
"document_blocked": "#/$defs/DocumentBlockedEvent",
1151611617
"document_create_check": "#/$defs/DocumentCreateCheckEvent",
1151711618
"document_field_calculation": "#/$defs/DocumentFieldCalculationEvent",
1151811619
"document_modify_check": "#/$defs/DocumentModifyCheckEvent",
@@ -11524,6 +11625,7 @@
1152411625
"engineering_change_status_change_check": "#/$defs/EngineeringChangeStatusChangeCheckEvent",
1152511626
"engineering_change_status_changed": "#/$defs/EngineeringChangeStatusChangedEvent",
1152611627
"field_value_calculation": "#/$defs/FieldValueCalculationEvent",
11628+
"part_blocked": "#/$defs/PartBlockedEvent",
1152711629
"part_create_check": "#/$defs/PartCreateCheckEvent",
1152811630
"part_field_calculation": "#/$defs/PartFieldCalculationEvent",
1152911631
"part_modify_check": "#/$defs/PartModifyCheckEvent",
@@ -11534,6 +11636,9 @@
1153411636
"propertyName": "name"
1153511637
},
1153611638
"oneOf": [
11639+
{
11640+
"$ref": "#/$defs/DocumentBlockedEvent"
11641+
},
1153711642
{
1153811643
"$ref": "#/$defs/DocumentReleasedEvent"
1153911644
},
@@ -11543,6 +11648,9 @@
1154311648
{
1154411649
"$ref": "#/$defs/DocumentFieldCalculationEvent"
1154511650
},
11651+
{
11652+
"$ref": "#/$defs/PartBlockedEvent"
11653+
},
1154611654
{
1154711655
"$ref": "#/$defs/PartReleasedEvent"
1154811656
},

0 commit comments

Comments
 (0)