Skip to content
Merged
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
10 changes: 10 additions & 0 deletions csfunctions/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from .dialog_data import DocumentReleaseDialogData, PartReleaseDialogData
from .document_create_check import DocumentCreateCheckData, DocumentCreateCheckEvent
from .document_field_calculation import DocumentFieldCalculationData, DocumentFieldCalculationEvent
from .document_modify_check import DocumentModifyCheckData, DocumentModifyCheckEvent
from .document_release import DocumentReleaseData, DocumentReleaseEvent
from .document_release_check import DocumentReleaseCheckData, DocumentReleaseCheckEvent
Expand All @@ -12,6 +13,7 @@
from .engineering_change_release_check import EngineeringChangeReleaseCheck, EngineeringChangeReleaseCheckData
from .field_value_calculation import FieldValueCalculationData, FieldValueCalculationEvent
from .part_create_check import PartCreateCheckData, PartCreateCheckEvent
from .part_field_calculation import PartFieldCalculationData, PartFieldCalculationEvent
from .part_modify_check import PartModifyCheckData, PartModifyCheckEvent
from .part_release import PartReleaseData, PartReleaseEvent
from .part_release_check import PartReleaseCheckData, PartReleaseCheckEvent
Expand All @@ -21,8 +23,10 @@
Union[
DocumentReleaseEvent,
DocumentReleaseCheckEvent,
DocumentFieldCalculationEvent,
PartReleaseEvent,
PartReleaseCheckEvent,
PartFieldCalculationEvent,
FieldValueCalculationEvent,
DummyEvent,
EngineeringChangeRelease,
Expand All @@ -38,8 +42,10 @@
EventData = Union[
DocumentReleaseData,
DocumentReleaseCheckData,
DocumentFieldCalculationData,
PartReleaseData,
PartReleaseCheckData,
PartFieldCalculationData,
FieldValueCalculationData,
DummyEventData,
EngineeringChangeReleaseData,
Expand All @@ -54,15 +60,18 @@
__all__ = [
"DocumentReleaseEvent",
"DocumentReleaseCheckEvent",
"DocumentFieldCalculationEvent",
"PartReleaseEvent",
"PartReleaseCheckEvent",
"PartFieldCalculationEvent",
"FieldValueCalculationEvent",
"DummyEvent",
"EngineeringChangeRelease",
"EngineeringChangeReleaseCheck",
"WorkflowTaskTriggerEvent",
"DocumentReleaseData",
"DocumentReleaseCheckData",
"DocumentFieldCalculationData",
"PartReleaseData",
"PartReleaseCheckData",
"FieldValueCalculationData",
Expand All @@ -72,6 +81,7 @@
"WorkflowTaskTriggerEventData",
"DocumentReleaseDialogData",
"PartReleaseDialogData",
"PartFieldCalculationData",
"DocumentCreateCheckData",
"DocumentCreateCheckEvent",
"DocumentModifyCheckData",
Expand Down
2 changes: 2 additions & 0 deletions csfunctions/events/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ class EventNames(str, Enum):
DUMMY = "dummy"
DOCUMENT_RELEASE = "document_release"
DOCUMENT_RELEASE_CHECK = "document_release_check"
DOCUMENT_FIELD_CALCULATION = "document_field_calculation"
PART_RELEASE = "part_release"
PART_RELEASE_CHECK = "part_release_check"
PART_FIELD_CALCULATION = "part_field_calculation"
ENGINEERING_CHANGE_RELEASE = "engineering_change_release"
ENGINEERING_CHANGE_RELEASE_CHECK = "engineering_change_release_check"
FIELD_VALUE_CALCULATION = "field_value_calculation"
Expand Down
18 changes: 18 additions & 0 deletions csfunctions/events/document_field_calculation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import Literal

from pydantic import BaseModel, Field

from csfunctions.objects import Document, Part

from .base import BaseEvent, EventNames


class DocumentFieldCalculationData(BaseModel):
document: Document = Field(..., description="Current state of the document")
action: Literal["create", "modify", "copy", "index"] = Field(..., description="Action being performed")
linked_parts: list[Part] = Field(..., description="Parts that belong to the document")


class DocumentFieldCalculationEvent(BaseEvent):
name: Literal[EventNames.DOCUMENT_FIELD_CALCULATION] = EventNames.DOCUMENT_FIELD_CALCULATION
data: DocumentFieldCalculationData
19 changes: 19 additions & 0 deletions csfunctions/events/part_field_calculation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from typing import Literal

from pydantic import BaseModel, Field

from csfunctions.objects import Document, Part

from .base import BaseEvent, EventNames


class PartFieldCalculationData(BaseModel):
part: Part = Field(..., description="Current state of the part")
action: Literal["create", "modify", "copy", "index"] = Field(..., description="Action being performed")

linked_documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")


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


## DocumentFieldCalculationEvent
`csfunctions.events.DocumentFieldCalculationEvent`

This event is fired when a document is created, modified, copied or indexed. It is triggered after the field calculations defined in the datasheet editor are performed.

The event expects a DataResponse containing a dictionary of field names and their new values. Fields that are not mentioned in the response are not updated.


**DocumentFieldCalculationEvent.name:** document_field_calculation

**DocumentFieldCalculationEvent.data:**

|Attribute|Type|Description|
|-|-|-|
|document|[Document](objects.md#document)|Current state of the document|
|action|Literal["create", "modify", "copy", "index"]|Action being performed|
|linked_parts|list[[Part](objects.md#part)]|Parts that belong to the document|



## EngineeringChangeReleaseCheck
`csfunctions.events.EngineeringChangeReleaseCheck`

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


## PartFieldCalculationEvent
`csfunctions.events.PartFieldCalculationEvent`

This event is fired when a part is created, modified, copied or indexed. It is triggered after the field calculations defined in the datasheet editor are performed.

The event expects a DataResponse containing a dictionary of field names and their new values. Fields that are not mentioned in the response are not updated.

**PartFieldCalculationEvent.name:** part_field_calculation

**PartFieldCalculationEvent.data:**

|Attribute|Type|Description|
|-|-|-|
|part|[Part](objects.md#part)|Current state of the part|
|action|Literal["create", "modify", "copy", "index"]|Action being performed|
|linked_documents| list[[Document](objects.md#document)]|List of documents that belong to the part|


## WorkflowTaskTriggerEvent
`csfunctions.events.WorkflowTaskTriggerEvent`

Expand Down
124 changes: 124 additions & 0 deletions json_schemas/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,64 @@
"title": "DocumentCreateCheckEvent",
"type": "object"
},
"DocumentFieldCalculationData": {
"properties": {
"document": {
"$ref": "#/$defs/Document",
"description": "Current state of the document"
},
"action": {
"description": "Action being performed",
"enum": [
"create",
"modify",
"copy",
"index"
],
"title": "Action",
"type": "string"
},
"linked_parts": {
"description": "Parts that belong to the document",
"items": {
"$ref": "#/$defs/Part"
},
"title": "Linked Parts",
"type": "array"
}
},
"required": [
"document",
"action",
"linked_parts"
],
"title": "DocumentFieldCalculationData",
"type": "object"
},
"DocumentFieldCalculationEvent": {
"properties": {
"name": {
"const": "document_field_calculation",
"default": "document_field_calculation",
"title": "Name",
"type": "string"
},
"event_id": {
"description": "unique identifier",
"title": "Event Id",
"type": "string"
},
"data": {
"$ref": "#/$defs/DocumentFieldCalculationData"
}
},
"required": [
"event_id",
"data"
],
"title": "DocumentFieldCalculationEvent",
"type": "object"
},
"DocumentModifyCheckData": {
"properties": {
"documents": {
Expand Down Expand Up @@ -2573,6 +2631,64 @@
"title": "PartCreateCheckEvent",
"type": "object"
},
"PartFieldCalculationData": {
"properties": {
"part": {
"$ref": "#/$defs/Part",
"description": "Current state of the part"
},
"action": {
"description": "Action being performed",
"enum": [
"create",
"modify",
"copy",
"index"
],
"title": "Action",
"type": "string"
},
"linked_documents": {
"description": "List of documents that are referenced by the parts.",
"items": {
"$ref": "#/$defs/Document"
},
"title": "Linked Documents",
"type": "array"
}
},
"required": [
"part",
"action",
"linked_documents"
],
"title": "PartFieldCalculationData",
"type": "object"
},
"PartFieldCalculationEvent": {
"properties": {
"name": {
"const": "part_field_calculation",
"default": "part_field_calculation",
"title": "Name",
"type": "string"
},
"event_id": {
"description": "unique identifier",
"title": "Event Id",
"type": "string"
},
"data": {
"$ref": "#/$defs/PartFieldCalculationData"
}
},
"required": [
"event_id",
"data"
],
"title": "PartFieldCalculationEvent",
"type": "object"
},
"PartModifyCheckData": {
"properties": {
"parts": {
Expand Down Expand Up @@ -2950,6 +3066,7 @@
"discriminator": {
"mapping": {
"document_create_check": "#/$defs/DocumentCreateCheckEvent",
"document_field_calculation": "#/$defs/DocumentFieldCalculationEvent",
"document_modify_check": "#/$defs/DocumentModifyCheckEvent",
"document_release": "#/$defs/DocumentReleaseEvent",
"document_release_check": "#/$defs/DocumentReleaseCheckEvent",
Expand All @@ -2958,6 +3075,7 @@
"engineering_change_release_check": "#/$defs/EngineeringChangeReleaseCheck",
"field_value_calculation": "#/$defs/FieldValueCalculationEvent",
"part_create_check": "#/$defs/PartCreateCheckEvent",
"part_field_calculation": "#/$defs/PartFieldCalculationEvent",
"part_modify_check": "#/$defs/PartModifyCheckEvent",
"part_release": "#/$defs/PartReleaseEvent",
"part_release_check": "#/$defs/PartReleaseCheckEvent",
Expand All @@ -2972,12 +3090,18 @@
{
"$ref": "#/$defs/DocumentReleaseCheckEvent"
},
{
"$ref": "#/$defs/DocumentFieldCalculationEvent"
},
{
"$ref": "#/$defs/PartReleaseEvent"
},
{
"$ref": "#/$defs/PartReleaseCheckEvent"
},
{
"$ref": "#/$defs/PartFieldCalculationEvent"
},
{
"$ref": "#/$defs/FieldValueCalculationEvent"
},
Expand Down
Loading