Skip to content

Commit

Permalink
updated typeddicts to be simpler w/ burnettk
Browse files Browse the repository at this point in the history
  • Loading branch information
jasquat committed Oct 17, 2023
1 parent 88bcbaf commit 022c018
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/spiffworkflow_connector_command/command_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,26 @@ class CommandErrorDict(TypedDict):
message: str


class CommandResponseDict(TypedDict):
"""This is given to the service task as task data."""

body: Any
mimetype: str

http_status: NotRequired[int | None]


class ConnectorProxyResponseDict(TypedDict):
"""This is passed back to spiffworkflow-backend as the response body."""

# this is given to the service task as task data
command_response: dict
command_response: CommandResponseDict
error: CommandErrorDict | None
command_response_version: int

# these are printed to spiffworkflow-backend logs
spiff__logs: NotRequired[list[str]| None]


class CommandResultDictV2(TypedDict):
"""spiffworkflow-proxy parses this result to determine what happended."""

# allow returning string for backwards compatibility
response: ConnectorProxyResponseDict

status: int
mimetype: str


class CommandResultDictV1(TypedDict):
"""spiffworkflow-proxy parses this result to determine what happended."""

Expand All @@ -52,7 +51,7 @@ class ConnectorCommand(metaclass=abc.ABCMeta):
"""Abstract class to describe how to make a command."""

@abc.abstractmethod
def execute(self, config: Any, task_data: dict) -> CommandResultDictV1 | CommandResultDictV2:
def execute(self, config: Any, task_data: dict) -> CommandResultDictV1 | ConnectorProxyResponseDict:
raise NotImplementedError("method must be implemented on subclass: execute")

# this is not a required method but if it gets used then it must be overridden
Expand Down

0 comments on commit 022c018

Please sign in to comment.