Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions csfunctions/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
CustomOperationPartEvent,
)
from .dialog_data import DocumentReleasedDialogData, PartReleasedDialogData
from .document_blocked import DocumentBlockedData, DocumentBlockedEvent
from .document_create_check import DocumentCreateCheckData, DocumentCreateCheckEvent
from .document_field_calculation import DocumentFieldCalculationData, DocumentFieldCalculationEvent
from .document_modify_check import DocumentModifyCheckData, DocumentModifyCheckEvent
Expand All @@ -32,6 +33,7 @@
)
from .engineering_change_status_changed import EngineeringChangeStatusChangedData, EngineeringChangeStatusChangedEvent
from .field_value_calculation import FieldValueCalculationData, FieldValueCalculationEvent
from .part_blocked import PartBlockedData, PartBlockedEvent
from .part_create_check import PartCreateCheckData, PartCreateCheckEvent
from .part_field_calculation import PartFieldCalculationData, PartFieldCalculationEvent
from .part_modify_check import PartModifyCheckData, PartModifyCheckEvent
Expand All @@ -40,9 +42,11 @@
from .workflow_task_trigger import WorkflowTaskTriggerEvent, WorkflowTaskTriggerEventData

Event = Annotated[
DocumentReleasedEvent
DocumentBlockedEvent
| DocumentReleasedEvent
| DocumentReleaseCheckEvent
| DocumentFieldCalculationEvent
| PartBlockedEvent
| PartReleasedEvent
| PartReleaseCheckEvent
| PartFieldCalculationEvent
Expand Down Expand Up @@ -71,9 +75,11 @@
Field(discriminator="name"),
]
EventData = (
DocumentReleasedData
DocumentBlockedData
| DocumentReleasedData
| DocumentReleaseCheckData
| DocumentFieldCalculationData
| PartBlockedData
| PartReleasedData
| PartReleaseCheckData
| PartFieldCalculationData
Expand Down Expand Up @@ -102,9 +108,11 @@
)

__all__ = [
"DocumentBlockedEvent",
"DocumentReleasedEvent",
"DocumentReleaseCheckEvent",
"DocumentFieldCalculationEvent",
"PartBlockedEvent",
"PartReleasedEvent",
"PartReleaseCheckEvent",
"PartFieldCalculationEvent",
Expand All @@ -124,9 +132,11 @@
"ChangeRequestStatusChangedEvent",
"ChangeRequestStatusChangeCheckEvent",
"WorkflowTaskTriggerEvent",
"DocumentBlockedData",
"DocumentReleasedData",
"DocumentReleaseCheckData",
"DocumentFieldCalculationData",
"PartBlockedData",
"PartReleasedData",
"PartReleaseCheckData",
"BOMItemFieldCalculationData",
Expand Down
2 changes: 2 additions & 0 deletions csfunctions/events/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

class EventNames(str, Enum):
DUMMY = "dummy"
DOCUMENT_BLOCKED = "document_blocked"
DOCUMENT_RELEASED = "document_released"
DOCUMENT_RELEASE_CHECK = "document_release_check"
DOCUMENT_FIELD_CALCULATION = "document_field_calculation"
PART_BLOCKED = "part_blocked"
PART_RELEASED = "part_released"
PART_RELEASE_CHECK = "part_release_check"
PART_FIELD_CALCULATION = "part_field_calculation"
Expand Down
17 changes: 17 additions & 0 deletions csfunctions/events/document_blocked.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from typing import Literal

from pydantic import BaseModel, Field

from csfunctions.objects import Document, Part

from .base import BaseEvent, EventNames


class DocumentBlockedData(BaseModel):
documents: list[Document] = Field(..., description="List of documents that were blocked.")
parts: list[Part] = Field(..., description="List of parts that belong to the documents.")


class DocumentBlockedEvent(BaseEvent):
name: Literal[EventNames.DOCUMENT_BLOCKED] = EventNames.DOCUMENT_BLOCKED
data: DocumentBlockedData
17 changes: 17 additions & 0 deletions csfunctions/events/part_blocked.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from typing import Literal

from pydantic import BaseModel, Field

from csfunctions.objects import Document, Part

from .base import BaseEvent, EventNames


class PartBlockedData(BaseModel):
parts: list[Part] = Field(..., description="List of parts that were blocked.")
documents: list[Document] = Field(..., description="List of documents that belong to the parts.")


class PartBlockedEvent(BaseEvent):
name: Literal[EventNames.PART_BLOCKED] = EventNames.PART_BLOCKED
data: PartBlockedData
36 changes: 36 additions & 0 deletions docs/reference/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ This event is fired **after** a document has been released. Raising an exception
| cdb_ec_id | str \| None | Engineering Change ID |


## DocumentBlockedEvent
`csfunctions.events.DocumentBlockedEvent`

This event is fired **after** a document has been blocked (status set to 170). Raising an exception thus can not prevent the blocking.

**Supported actions:**

- [StartWorkflowAction](actions.md#startworkflowaction)

**DocumentBlockedEvent.name:** document_blocked

**DocumentBlockedEvent.data:**

| Attribute | Type | Description |
| --------- | ------------------------------------- | ------------------------------------------- |
| documents | list[[Document](objects.md#document)] | List of documents that were blocked. |
| parts | list[[Part](objects.md#part)] | List of parts that belong to the documents. |

## DocumentFieldCalculationEvent
`csfunctions.events.DocumentFieldCalculationEvent`

Expand Down Expand Up @@ -405,6 +423,24 @@ This event is fired **after** a part has been released. Raising an exception thu
| cdb_ec_id | str \| None | Engineering Change ID |


## PartBlockedEvent
`csfunctions.events.PartBlockedEvent`

This event is fired **after** a part has been blocked (status set to 170). Raising an exception thus can not prevent the blocking.

**Supported actions:**

- [StartWorkflowAction](actions.md#startworkflowaction)

**PartBlockedEvent.name:** part_blocked

**PartBlockedEvent.data:**

| Attribute | Type | Description |
| --------- | ------------------------------------- | ---------------------------------------- |
| parts | list[[Part](objects.md#part)] | List of parts that were blocked. |
| documents | list[[Document](objects.md#document)] | List of documents that belong to the parts. |

## PartFieldCalculationEvent
`csfunctions.events.PartFieldCalculationEvent`

Expand Down
3 changes: 3 additions & 0 deletions docs/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ hide:
- toc
---

### Version 0.27.0
- Feat: Add part_blocked and document_blocked events

### Version 0.26.0
- Feat: Extend all multi-language object fields with Japanese (ja) and Chinese (zh) variants

Expand Down
108 changes: 108 additions & 0 deletions json_schemas/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -7235,6 +7235,56 @@
"title": "Document",
"type": "object"
},
"DocumentBlockedData": {
"properties": {
"documents": {
"description": "List of documents that were blocked.",
"items": {
"$ref": "#/$defs/Document"
},
"title": "Documents",
"type": "array"
},
"parts": {
"description": "List of parts that belong to the documents.",
"items": {
"$ref": "#/$defs/Part"
},
"title": "Parts",
"type": "array"
}
},
"required": [
"documents",
"parts"
],
"title": "DocumentBlockedData",
"type": "object"
},
"DocumentBlockedEvent": {
"properties": {
"name": {
"const": "document_blocked",
"default": "document_blocked",
"title": "Name",
"type": "string"
},
"event_id": {
"description": "unique identifier",
"title": "Event Id",
"type": "string"
},
"data": {
"$ref": "#/$defs/DocumentBlockedData"
}
},
"required": [
"event_id",
"data"
],
"title": "DocumentBlockedEvent",
"type": "object"
},
"DocumentCreateCheckData": {
"properties": {
"documents": {
Expand Down Expand Up @@ -10959,6 +11009,56 @@
"title": "Part",
"type": "object"
},
"PartBlockedData": {
"properties": {
"parts": {
"description": "List of parts that were blocked.",
"items": {
"$ref": "#/$defs/Part"
},
"title": "Parts",
"type": "array"
},
"documents": {
"description": "List of documents that belong to the parts.",
"items": {
"$ref": "#/$defs/Document"
},
"title": "Documents",
"type": "array"
}
},
"required": [
"parts",
"documents"
],
"title": "PartBlockedData",
"type": "object"
},
"PartBlockedEvent": {
"properties": {
"name": {
"const": "part_blocked",
"default": "part_blocked",
"title": "Name",
"type": "string"
},
"event_id": {
"description": "unique identifier",
"title": "Event Id",
"type": "string"
},
"data": {
"$ref": "#/$defs/PartBlockedData"
}
},
"required": [
"event_id",
"data"
],
"title": "PartBlockedEvent",
"type": "object"
},
"PartCreateCheckData": {
"properties": {
"parts": {
Expand Down Expand Up @@ -11472,6 +11572,7 @@
"change_request_status_changed": "#/$defs/ChangeRequestStatusChangedEvent",
"custom_operation_document": "#/$defs/CustomOperationDocumentEvent",
"custom_operation_part": "#/$defs/CustomOperationPartEvent",
"document_blocked": "#/$defs/DocumentBlockedEvent",
"document_create_check": "#/$defs/DocumentCreateCheckEvent",
"document_field_calculation": "#/$defs/DocumentFieldCalculationEvent",
"document_modify_check": "#/$defs/DocumentModifyCheckEvent",
Expand All @@ -11483,6 +11584,7 @@
"engineering_change_status_change_check": "#/$defs/EngineeringChangeStatusChangeCheckEvent",
"engineering_change_status_changed": "#/$defs/EngineeringChangeStatusChangedEvent",
"field_value_calculation": "#/$defs/FieldValueCalculationEvent",
"part_blocked": "#/$defs/PartBlockedEvent",
"part_create_check": "#/$defs/PartCreateCheckEvent",
"part_field_calculation": "#/$defs/PartFieldCalculationEvent",
"part_modify_check": "#/$defs/PartModifyCheckEvent",
Expand All @@ -11493,6 +11595,9 @@
"propertyName": "name"
},
"oneOf": [
{
"$ref": "#/$defs/DocumentBlockedEvent"
},
{
"$ref": "#/$defs/DocumentReleasedEvent"
},
Expand All @@ -11502,6 +11607,9 @@
{
"$ref": "#/$defs/DocumentFieldCalculationEvent"
},
{
"$ref": "#/$defs/PartBlockedEvent"
},
{
"$ref": "#/$defs/PartReleasedEvent"
},
Expand Down
Loading