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
24 changes: 22 additions & 2 deletions csfunctions/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
)
from .dialog_data import DocumentReleasedDialogData, PartReleasedDialogData
from .document_create_check import DocumentCreateCheckData, DocumentCreateCheckEvent
from .document_created import DocumentCreatedData, DocumentCreatedEvent
from .document_field_calculation import DocumentFieldCalculationData, DocumentFieldCalculationEvent
from .document_indexed import DocumentIndexedData, DocumentIndexedEvent
from .document_modify_check import DocumentModifyCheckData, DocumentModifyCheckEvent
from .document_release_check import DocumentReleaseCheckData, DocumentReleaseCheckEvent
from .document_released import DocumentReleasedData, DocumentReleasedEvent
Expand All @@ -33,16 +35,22 @@
from .engineering_change_status_changed import EngineeringChangeStatusChangedData, EngineeringChangeStatusChangedEvent
from .field_value_calculation import FieldValueCalculationData, FieldValueCalculationEvent
from .part_create_check import PartCreateCheckData, PartCreateCheckEvent
from .part_created import PartCreatedData, PartCreatedEvent
from .part_field_calculation import PartFieldCalculationData, PartFieldCalculationEvent
from .part_indexed import PartIndexedData, PartIndexedEvent
from .part_modify_check import PartModifyCheckData, PartModifyCheckEvent
from .part_release_check import PartReleaseCheckData, PartReleaseCheckEvent
from .part_released import PartReleasedData, PartReleasedEvent
from .workflow_task_trigger import WorkflowTaskTriggerEvent, WorkflowTaskTriggerEventData

Event = Annotated[
DocumentReleasedEvent
DocumentCreatedEvent
| DocumentIndexedEvent
| DocumentReleasedEvent
| DocumentReleaseCheckEvent
| DocumentFieldCalculationEvent
| PartCreatedEvent
| PartIndexedEvent
| PartReleasedEvent
| PartReleaseCheckEvent
| PartFieldCalculationEvent
Expand Down Expand Up @@ -71,9 +79,13 @@
Field(discriminator="name"),
]
EventData = (
DocumentReleasedData
DocumentCreatedData
| DocumentIndexedData
| DocumentReleasedData
| DocumentReleaseCheckData
| DocumentFieldCalculationData
| PartCreatedData
| PartIndexedData
| PartReleasedData
| PartReleaseCheckData
| PartFieldCalculationData
Expand Down Expand Up @@ -102,9 +114,13 @@
)

__all__ = [
"DocumentCreatedEvent",
"DocumentIndexedEvent",
"DocumentReleasedEvent",
"DocumentReleaseCheckEvent",
"DocumentFieldCalculationEvent",
"PartCreatedEvent",
"PartIndexedEvent",
"PartReleasedEvent",
"PartReleaseCheckEvent",
"PartFieldCalculationEvent",
Expand All @@ -124,9 +140,13 @@
"ChangeRequestStatusChangedEvent",
"ChangeRequestStatusChangeCheckEvent",
"WorkflowTaskTriggerEvent",
"DocumentCreatedData",
"DocumentIndexedData",
"DocumentReleasedData",
"DocumentReleaseCheckData",
"DocumentFieldCalculationData",
"PartCreatedData",
"PartIndexedData",
"PartReleasedData",
"PartReleaseCheckData",
"BOMItemFieldCalculationData",
Expand Down
4 changes: 4 additions & 0 deletions csfunctions/events/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@

class EventNames(str, Enum):
DUMMY = "dummy"
DOCUMENT_CREATED = "document_created"
DOCUMENT_INDEXED = "document_indexed"
DOCUMENT_RELEASED = "document_released"
DOCUMENT_RELEASE_CHECK = "document_release_check"
DOCUMENT_FIELD_CALCULATION = "document_field_calculation"
PART_CREATED = "part_created"
PART_INDEXED = "part_indexed"
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_created.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 DocumentCreatedData(BaseModel):
documents: list[Document] = Field(..., description="List of documents that were created.")
parts: list[Part] = Field(..., description="List of parts that belong to the documents.")


class DocumentCreatedEvent(BaseEvent):
name: Literal[EventNames.DOCUMENT_CREATED] = EventNames.DOCUMENT_CREATED
data: DocumentCreatedData
17 changes: 17 additions & 0 deletions csfunctions/events/document_indexed.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 DocumentIndexedData(BaseModel):
documents: list[Document] = Field(..., description="List of documents that were indexed.")
parts: list[Part] = Field(..., description="List of parts that belong to the documents.")


class DocumentIndexedEvent(BaseEvent):
name: Literal[EventNames.DOCUMENT_INDEXED] = EventNames.DOCUMENT_INDEXED
data: DocumentIndexedData
17 changes: 17 additions & 0 deletions csfunctions/events/part_created.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 PartCreatedData(BaseModel):
parts: list[Part] = Field(..., description="List of parts that were created.")
documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")


class PartCreatedEvent(BaseEvent):
name: Literal[EventNames.PART_CREATED] = EventNames.PART_CREATED
data: PartCreatedData
17 changes: 17 additions & 0 deletions csfunctions/events/part_indexed.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 PartIndexedData(BaseModel):
parts: list[Part] = Field(..., description="List of parts that were indexed.")
documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")


class PartIndexedEvent(BaseEvent):
name: Literal[EventNames.PART_INDEXED] = EventNames.PART_INDEXED
data: PartIndexedData
72 changes: 72 additions & 0 deletions docs/reference/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,42 @@ The event is triggered before any field calculations are performed.
| documents | list[[Document](objects.md#document)] | List of documents that are about to be created. |
| parts | list[[Part](objects.md#part)] | List of parts that belong to the documents. |

## DocumentCreatedEvent
`csfunctions.events.DocumentCreatedEvent`

This event is fired **after** a document has been created. Raising an exception thus can not prevent the creation.

**Supported actions:**

- [StartWorkflowAction](actions.md#startworkflowaction)

**DocumentCreatedEvent.name:** document_created

**DocumentCreatedEvent.data:**

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

## DocumentIndexedEvent
`csfunctions.events.DocumentIndexedEvent`

This event is fired **after** a document has been indexed. Raising an exception thus can not prevent the indexing.

**Supported actions:**

- [StartWorkflowAction](actions.md#startworkflowaction)

**DocumentIndexedEvent.name:** document_indexed

**DocumentIndexedEvent.data:**

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

## DocumentModifyCheckEvent
`csfunctions.events.DocumentModifyCheckEvent`

Expand Down Expand Up @@ -331,6 +367,42 @@ The event is triggered before any field calculations are performed.
| parts | list[[Part](objects.md#part)] | List of parts that are about to be created. |
| documents | list[[Document](objects.md#document)] | List of documents that are referenced by the parts. |

## PartCreatedEvent
`csfunctions.events.PartCreatedEvent`

This event is fired **after** a part has been created. Raising an exception thus can not prevent the creation.

**Supported actions:**

- [StartWorkflowAction](actions.md#startworkflowaction)

**PartCreatedEvent.name:** part_created

**PartCreatedEvent.data:**

| Attribute | Type | Description |
| --------- | ------------------------------------- | --------------------------------------------------- |
| parts | list[[Part](objects.md#part)] | List of parts that were created. |
| documents | list[[Document](objects.md#document)] | List of documents that are referenced by the parts. |

## PartIndexedEvent
`csfunctions.events.PartIndexedEvent`

This event is fired **after** a part has been indexed. Raising an exception thus can not prevent the indexing.

**Supported actions:**

- [StartWorkflowAction](actions.md#startworkflowaction)

**PartIndexedEvent.name:** part_indexed

**PartIndexedEvent.data:**

| Attribute | Type | Description |
| --------- | ------------------------------------- | --------------------------------------------------- |
| parts | list[[Part](objects.md#part)] | List of parts that were indexed. |
| documents | list[[Document](objects.md#document)] | List of documents that are referenced by the parts. |

## PartModifyCheckEvent
`csfunctions.events.PartModifyCheckEvent`

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

### Version next
- Feat: Add part_created and document_created events
- Feat: Add part_indexed and document_indexed events

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

Expand Down
Loading
Loading