File tree Expand file tree Collapse file tree 4 files changed +82
-0
lines changed
Expand file tree Collapse file tree 4 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 22
33from pydantic import Field
44
5+ from .custom_operations import CustomOperationDocumentData , CustomOperationDocumentEvent
56from .dialog_data import DocumentReleasedDialogData , PartReleasedDialogData
67from .document_create_check import DocumentCreateCheckData , DocumentCreateCheckEvent
78from .document_field_calculation import DocumentFieldCalculationData , DocumentFieldCalculationEvent
3637 DocumentModifyCheckEvent ,
3738 PartCreateCheckEvent ,
3839 PartModifyCheckEvent ,
40+ CustomOperationDocumentEvent ,
3941 ],
4042 Field (discriminator = "name" ),
4143]
5557 DocumentModifyCheckData ,
5658 PartCreateCheckData ,
5759 PartModifyCheckData ,
60+ CustomOperationDocumentData ,
5861]
5962
6063__all__ = [
9093 "PartCreateCheckEvent" ,
9194 "PartModifyCheckData" ,
9295 "PartModifyCheckEvent" ,
96+ "CustomOperationDocumentData" ,
97+ "CustomOperationDocumentEvent" ,
9398]
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ class EventNames(str, Enum):
1919 DOCUMENT_MODIFY_CHECK = "document_modify_check"
2020 PART_CREATE_CHECK = "part_create_check"
2121 PART_MODIFY_CHECK = "part_modify_check"
22+ CUSTOM_OPERATION_DOCUMENT = "custom_operation_document"
2223
2324
2425class BaseEvent (BaseModel ):
Original file line number Diff line number Diff line change 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 CustomOperationDocumentData (BaseModel ):
11+ documents : list [Document ] = Field (..., description = "List of documents that the custom operation was called on" )
12+ parts : list [Part ] = Field (..., description = "List of parts that belong to the documents" )
13+
14+
15+ class CustomOperationDocumentEvent (BaseEvent ):
16+ """
17+ Event triggered when a custom operation is called on a document.
18+ """
19+
20+ name : Literal [EventNames .CUSTOM_OPERATION_DOCUMENT ] = EventNames .CUSTOM_OPERATION_DOCUMENT
21+ data : CustomOperationDocumentData
Original file line number Diff line number Diff line change 8585 "title" : " Briefcase" ,
8686 "type" : " object"
8787 },
88+ "CustomOperationDocumentData" : {
89+ "properties" : {
90+ "documents" : {
91+ "description" : " List of documents that the custom operation was called on" ,
92+ "items" : {
93+ "$ref" : " #/$defs/Document"
94+ },
95+ "title" : " Documents" ,
96+ "type" : " array"
97+ },
98+ "parts" : {
99+ "description" : " List of parts that belong to the documents" ,
100+ "items" : {
101+ "$ref" : " #/$defs/Part"
102+ },
103+ "title" : " Parts" ,
104+ "type" : " array"
105+ }
106+ },
107+ "required" : [
108+ " documents" ,
109+ " parts"
110+ ],
111+ "title" : " CustomOperationDocumentData" ,
112+ "type" : " object"
113+ },
114+ "CustomOperationDocumentEvent" : {
115+ "description" : " Event triggered when a custom operation is called on a document." ,
116+ "properties" : {
117+ "name" : {
118+ "const" : " custom_operation_document" ,
119+ "default" : " custom_operation_document" ,
120+ "title" : " Name" ,
121+ "type" : " string"
122+ },
123+ "event_id" : {
124+ "description" : " unique identifier" ,
125+ "title" : " Event Id" ,
126+ "type" : " string"
127+ },
128+ "data" : {
129+ "$ref" : " #/$defs/CustomOperationDocumentData"
130+ }
131+ },
132+ "required" : [
133+ " event_id" ,
134+ " data"
135+ ],
136+ "title" : " CustomOperationDocumentEvent" ,
137+ "type" : " object"
138+ },
88139 "Document" : {
89140 "description" : " Normal Document that doesn't contain a CAD-Model." ,
90141 "properties" : {
30683119 "event" : {
30693120 "discriminator" : {
30703121 "mapping" : {
3122+ "custom_operation_document" : " #/$defs/CustomOperationDocumentEvent" ,
30713123 "document_create_check" : " #/$defs/DocumentCreateCheckEvent" ,
30723124 "document_field_calculation" : " #/$defs/DocumentFieldCalculationEvent" ,
30733125 "document_modify_check" : " #/$defs/DocumentModifyCheckEvent" ,
31313183 },
31323184 {
31333185 "$ref" : " #/$defs/PartModifyCheckEvent"
3186+ },
3187+ {
3188+ "$ref" : " #/$defs/CustomOperationDocumentEvent"
31343189 }
31353190 ],
31363191 "title" : " Event"
You can’t perform that action at this time.
0 commit comments