Skip to content

Commit 27e8120

Browse files
author
Jens Kürten
committed
feat: document field calculation event
1 parent 4bec539 commit 27e8120

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed

csfunctions/events/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pydantic import Field
44

55
from .dialog_data import DocumentReleaseDialogData, PartReleaseDialogData
6+
from .document_field_calculation import DocumentFieldCalculationData, DocumentFieldCalculationEvent
67
from .document_release import DocumentReleaseData, DocumentReleaseEvent
78
from .document_release_check import DocumentReleaseCheckData, DocumentReleaseCheckEvent
89
from .dummy import DummyEvent, DummyEventData
@@ -17,6 +18,7 @@
1718
Union[
1819
DocumentReleaseEvent,
1920
DocumentReleaseCheckEvent,
21+
DocumentFieldCalculationEvent,
2022
PartReleaseEvent,
2123
PartReleaseCheckEvent,
2224
FieldValueCalculationEvent,
@@ -30,6 +32,7 @@
3032
EventData = Union[
3133
DocumentReleaseData,
3234
DocumentReleaseCheckData,
35+
DocumentFieldCalculationData,
3336
PartReleaseData,
3437
PartReleaseCheckData,
3538
FieldValueCalculationData,
@@ -42,6 +45,7 @@
4245
__all__ = [
4346
"DocumentReleaseEvent",
4447
"DocumentReleaseCheckEvent",
48+
"DocumentFieldCalculationEvent",
4549
"PartReleaseEvent",
4650
"PartReleaseCheckEvent",
4751
"FieldValueCalculationEvent",
@@ -51,6 +55,7 @@
5155
"WorkflowTaskTriggerEvent",
5256
"DocumentReleaseData",
5357
"DocumentReleaseCheckData",
58+
"DocumentFieldCalculationData",
5459
"PartReleaseData",
5560
"PartReleaseCheckData",
5661
"FieldValueCalculationData",

csfunctions/events/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class EventNames(str, Enum):
77
DUMMY = "dummy"
88
DOCUMENT_RELEASE = "document_release"
99
DOCUMENT_RELEASE_CHECK = "document_release_check"
10+
DOCUMENT_FIELD_CALCULATION = "document_field_calculation"
1011
PART_RELEASE = "part_release"
1112
PART_RELEASE_CHECK = "part_release_check"
1213
ENGINEERING_CHANGE_RELEASE = "engineering_change_release"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 DocumentFieldCalculationData(BaseModel):
11+
document: Document = Field(..., description="Current state of the document")
12+
action: Literal["create", "modify", "copy", "index"] = Field(..., description="Action being performed")
13+
linked_parts: list[Part] = Field(..., description="Parts that belong to the document")
14+
linked_documents: list[Document] = Field(..., description="Related documents (e.g. source document)")
15+
16+
17+
class DocumentFieldCalculationEvent(BaseEvent):
18+
name: Literal[EventNames.DOCUMENT_FIELD_CALCULATION] = EventNames.DOCUMENT_FIELD_CALCULATION
19+
data: DocumentFieldCalculationData

json_schemas/request.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,73 @@
731731
"title": "Document",
732732
"type": "object"
733733
},
734+
"DocumentFieldCalculationData": {
735+
"properties": {
736+
"document": {
737+
"$ref": "#/$defs/Document",
738+
"description": "Current state of the document"
739+
},
740+
"action": {
741+
"description": "Action being performed",
742+
"enum": [
743+
"create",
744+
"modify",
745+
"copy",
746+
"index"
747+
],
748+
"title": "Action",
749+
"type": "string"
750+
},
751+
"linked_parts": {
752+
"description": "Parts that belong to the document",
753+
"items": {
754+
"$ref": "#/$defs/Part"
755+
},
756+
"title": "Linked Parts",
757+
"type": "array"
758+
},
759+
"linked_documents": {
760+
"description": "Related documents (e.g. source document)",
761+
"items": {
762+
"$ref": "#/$defs/Document"
763+
},
764+
"title": "Linked Documents",
765+
"type": "array"
766+
}
767+
},
768+
"required": [
769+
"document",
770+
"action",
771+
"linked_parts",
772+
"linked_documents"
773+
],
774+
"title": "DocumentFieldCalculationData",
775+
"type": "object"
776+
},
777+
"DocumentFieldCalculationEvent": {
778+
"properties": {
779+
"name": {
780+
"const": "document_field_calculation",
781+
"default": "document_field_calculation",
782+
"title": "Name",
783+
"type": "string"
784+
},
785+
"event_id": {
786+
"description": "unique identifier",
787+
"title": "Event Id",
788+
"type": "string"
789+
},
790+
"data": {
791+
"$ref": "#/$defs/DocumentFieldCalculationData"
792+
}
793+
},
794+
"required": [
795+
"event_id",
796+
"data"
797+
],
798+
"title": "DocumentFieldCalculationEvent",
799+
"type": "object"
800+
},
734801
"DocumentReleaseCheckData": {
735802
"properties": {
736803
"documents": {
@@ -2749,6 +2816,7 @@
27492816
"event": {
27502817
"discriminator": {
27512818
"mapping": {
2819+
"document_field_calculation": "#/$defs/DocumentFieldCalculationEvent",
27522820
"document_release": "#/$defs/DocumentReleaseEvent",
27532821
"document_release_check": "#/$defs/DocumentReleaseCheckEvent",
27542822
"dummy": "#/$defs/DummyEvent",
@@ -2768,6 +2836,9 @@
27682836
{
27692837
"$ref": "#/$defs/DocumentReleaseCheckEvent"
27702838
},
2839+
{
2840+
"$ref": "#/$defs/DocumentFieldCalculationEvent"
2841+
},
27712842
{
27722843
"$ref": "#/$defs/PartReleaseEvent"
27732844
},

0 commit comments

Comments
 (0)