use crate::codec::agent::{from_wire_agent_output, to_wire_agent_output};
use crate::codec::app::{
from_wire_agent_tool_ref, from_wire_subject_context, to_wire_agent_tool_ref,
to_wire_request_context, to_wire_subject_context,
};
use crate::codec::support::{
from_wire_struct, from_wire_timestamp, from_wire_value, to_wire_struct, to_wire_timestamp,
to_wire_value,
};
use crate::generated::v1;
use crate::workflow::{
ApplyWorkflowProviderDefinitionRequest, BoundWorkflowTarget, CancelWorkflowProviderRunRequest,
DeleteWorkflowProviderDefinitionRequest, DeliverWorkflowProviderEventRequest,
GetWorkflowProviderDefinitionRequest, GetWorkflowProviderRunEventsRequest,
GetWorkflowProviderRunEventsResponse, GetWorkflowProviderRunOutputRequest,
GetWorkflowProviderRunOutputResponse, GetWorkflowProviderRunRequest,
ListWorkflowProviderDefinitionsRequest, ListWorkflowProviderDefinitionsResponse,
ListWorkflowProviderRunsRequest, ListWorkflowProviderRunsResponse,
SetWorkflowProviderActivationPausedRequest, SetWorkflowProviderDefinitionPausedRequest,
SignalOrStartWorkflowProviderRunRequest, SignalWorkflowProviderRunRequest,
SignalWorkflowRunResponse, StartWorkflowProviderRunRequest, WorkflowActivation,
WorkflowActivationTrigger, WorkflowAgentMessage, WorkflowArray, WorkflowDefinition,
WorkflowDefinitionSpec, WorkflowEvent, WorkflowEventActivation, WorkflowEventMatch,
WorkflowEventTriggerInvocation, WorkflowManualTrigger, WorkflowObject, WorkflowPathSource,
WorkflowRun, WorkflowRunEvent, WorkflowRunTrigger, WorkflowRunTriggerKind,
WorkflowScheduleActivation, WorkflowScheduleTrigger, WorkflowSignal, WorkflowStep,
WorkflowStepAction, WorkflowStepAgentTurn, WorkflowStepAppCall, WorkflowStepAttempt,
WorkflowStepExecution, WorkflowStepInputSource, WorkflowStepOutputSource, WorkflowStepWhen,
WorkflowText, WorkflowValue, WorkflowValueKind,
};
pub(crate) fn to_wire_apply_workflow_provider_definition_request(
value: ApplyWorkflowProviderDefinitionRequest,
) -> v1::ApplyWorkflowProviderDefinitionRequest {
v1::ApplyWorkflowProviderDefinitionRequest {
provider_name: value.provider_name,
spec: value.spec.map(to_wire_workflow_definition_spec),
idempotency_key: value.idempotency_key,
requested_by_subject_id: value.requested_by_subject_id,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn to_wire_bound_workflow_target(value: BoundWorkflowTarget) -> v1::BoundWorkflowTarget {
v1::BoundWorkflowTarget {
steps: value.steps.into_iter().map(to_wire_workflow_step).collect(),
}
}
pub(crate) fn from_wire_bound_workflow_target(
value: v1::BoundWorkflowTarget,
) -> BoundWorkflowTarget {
BoundWorkflowTarget {
steps: value
.steps
.into_iter()
.map(from_wire_workflow_step)
.collect(),
}
}
pub(crate) fn to_wire_cancel_workflow_provider_run_request(
value: CancelWorkflowProviderRunRequest,
) -> v1::CancelWorkflowProviderRunRequest {
v1::CancelWorkflowProviderRunRequest {
run_id: value.run_id,
reason: value.reason,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn to_wire_delete_workflow_provider_definition_request(
value: DeleteWorkflowProviderDefinitionRequest,
) -> v1::DeleteWorkflowProviderDefinitionRequest {
v1::DeleteWorkflowProviderDefinitionRequest {
definition_id: value.definition_id,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn to_wire_deliver_workflow_provider_event_request(
value: DeliverWorkflowProviderEventRequest,
) -> v1::DeliverWorkflowProviderEventRequest {
v1::DeliverWorkflowProviderEventRequest {
app_name: value.app_name,
event: value.event.map(to_wire_workflow_event),
delivered_by_subject_id: value.delivered_by_subject_id,
provider_name: value.provider_name,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn to_wire_get_workflow_provider_definition_request(
value: GetWorkflowProviderDefinitionRequest,
) -> v1::GetWorkflowProviderDefinitionRequest {
v1::GetWorkflowProviderDefinitionRequest {
definition_id: value.definition_id,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn to_wire_get_workflow_provider_run_events_request(
value: GetWorkflowProviderRunEventsRequest,
) -> v1::GetWorkflowProviderRunEventsRequest {
v1::GetWorkflowProviderRunEventsRequest {
run_id: value.run_id,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn from_wire_get_workflow_provider_run_events_response(
value: v1::GetWorkflowProviderRunEventsResponse,
) -> GetWorkflowProviderRunEventsResponse {
GetWorkflowProviderRunEventsResponse {
events: value
.events
.into_iter()
.map(from_wire_workflow_run_event)
.collect(),
}
}
pub(crate) fn to_wire_get_workflow_provider_run_output_request(
value: GetWorkflowProviderRunOutputRequest,
) -> v1::GetWorkflowProviderRunOutputRequest {
v1::GetWorkflowProviderRunOutputRequest {
run_id: value.run_id,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn from_wire_get_workflow_provider_run_output_response(
value: v1::GetWorkflowProviderRunOutputResponse,
) -> GetWorkflowProviderRunOutputResponse {
GetWorkflowProviderRunOutputResponse {
output: value.output.map(from_wire_value),
}
}
pub(crate) fn to_wire_get_workflow_provider_run_request(
value: GetWorkflowProviderRunRequest,
) -> v1::GetWorkflowProviderRunRequest {
v1::GetWorkflowProviderRunRequest {
run_id: value.run_id,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn to_wire_list_workflow_provider_definitions_request(
value: ListWorkflowProviderDefinitionsRequest,
) -> v1::ListWorkflowProviderDefinitionsRequest {
v1::ListWorkflowProviderDefinitionsRequest {
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn from_wire_list_workflow_provider_definitions_response(
value: v1::ListWorkflowProviderDefinitionsResponse,
) -> ListWorkflowProviderDefinitionsResponse {
ListWorkflowProviderDefinitionsResponse {
definitions: value
.definitions
.into_iter()
.map(from_wire_workflow_definition)
.collect(),
}
}
pub(crate) fn to_wire_list_workflow_provider_runs_request(
value: ListWorkflowProviderRunsRequest,
) -> v1::ListWorkflowProviderRunsRequest {
v1::ListWorkflowProviderRunsRequest {
page_size: value.page_size,
page_token: value.page_token,
status: value.status,
target_app: value.target_app,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn from_wire_list_workflow_provider_runs_response(
value: v1::ListWorkflowProviderRunsResponse,
) -> ListWorkflowProviderRunsResponse {
ListWorkflowProviderRunsResponse {
runs: value.runs.into_iter().map(from_wire_workflow_run).collect(),
next_page_token: value.next_page_token,
}
}
pub(crate) fn to_wire_set_workflow_provider_activation_paused_request(
value: SetWorkflowProviderActivationPausedRequest,
) -> v1::SetWorkflowProviderActivationPausedRequest {
v1::SetWorkflowProviderActivationPausedRequest {
definition_id: value.definition_id,
activation_id: value.activation_id,
paused: value.paused,
requested_by_subject_id: value.requested_by_subject_id,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn to_wire_set_workflow_provider_definition_paused_request(
value: SetWorkflowProviderDefinitionPausedRequest,
) -> v1::SetWorkflowProviderDefinitionPausedRequest {
v1::SetWorkflowProviderDefinitionPausedRequest {
definition_id: value.definition_id,
paused: value.paused,
requested_by_subject_id: value.requested_by_subject_id,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn to_wire_signal_or_start_workflow_provider_run_request(
value: SignalOrStartWorkflowProviderRunRequest,
) -> v1::SignalOrStartWorkflowProviderRunRequest {
v1::SignalOrStartWorkflowProviderRunRequest {
workflow_key: value.workflow_key,
idempotency_key: value.idempotency_key,
created_by_subject_id: value.created_by_subject_id,
signal: value.signal.map(to_wire_workflow_signal),
provider_name: value.provider_name,
definition_id: value.definition_id,
run_as: value.run_as.map(to_wire_subject_context),
input: value.input.map(to_wire_struct),
expected_definition_generation: value.expected_definition_generation,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn to_wire_signal_workflow_provider_run_request(
value: SignalWorkflowProviderRunRequest,
) -> v1::SignalWorkflowProviderRunRequest {
v1::SignalWorkflowProviderRunRequest {
run_id: value.run_id,
signal: value.signal.map(to_wire_workflow_signal),
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn from_wire_signal_workflow_run_response(
value: v1::SignalWorkflowRunResponse,
) -> SignalWorkflowRunResponse {
SignalWorkflowRunResponse {
run: value.run.map(from_wire_workflow_run),
signal: value.signal.map(from_wire_workflow_signal),
started_run: value.started_run,
workflow_key: value.workflow_key,
}
}
pub(crate) fn to_wire_start_workflow_provider_run_request(
value: StartWorkflowProviderRunRequest,
) -> v1::StartWorkflowProviderRunRequest {
v1::StartWorkflowProviderRunRequest {
idempotency_key: value.idempotency_key,
created_by_subject_id: value.created_by_subject_id,
workflow_key: value.workflow_key,
provider_name: value.provider_name,
definition_id: value.definition_id,
run_as: value.run_as.map(to_wire_subject_context),
input: value.input.map(to_wire_struct),
expected_definition_generation: value.expected_definition_generation,
context: value.context.map(to_wire_request_context),
}
}
pub(crate) fn to_wire_workflow_activation(value: WorkflowActivation) -> v1::WorkflowActivation {
v1::WorkflowActivation {
id: value.id,
input: value.input.map(to_wire_workflow_value),
paused: value.paused,
trigger: value.trigger.map(to_wire_workflow_activation_trigger),
}
}
pub(crate) fn from_wire_workflow_activation(value: v1::WorkflowActivation) -> WorkflowActivation {
WorkflowActivation {
id: value.id,
input: value.input.map(from_wire_workflow_value),
paused: value.paused,
trigger: value.trigger.map(from_wire_workflow_activation_trigger),
}
}
pub(crate) fn to_wire_workflow_activation_trigger(
value: WorkflowActivationTrigger,
) -> v1::workflow_activation::Trigger {
match value {
WorkflowActivationTrigger::Schedule(value) => {
v1::workflow_activation::Trigger::Schedule(to_wire_workflow_schedule_activation(value))
}
WorkflowActivationTrigger::Event(value) => {
v1::workflow_activation::Trigger::Event(to_wire_workflow_event_activation(value))
}
}
}
pub(crate) fn from_wire_workflow_activation_trigger(
value: v1::workflow_activation::Trigger,
) -> WorkflowActivationTrigger {
match value {
v1::workflow_activation::Trigger::Schedule(value) => {
WorkflowActivationTrigger::Schedule(from_wire_workflow_schedule_activation(value))
}
v1::workflow_activation::Trigger::Event(value) => {
WorkflowActivationTrigger::Event(from_wire_workflow_event_activation(value))
}
}
}
pub(crate) fn to_wire_workflow_agent_message(
value: WorkflowAgentMessage,
) -> v1::WorkflowAgentMessage {
v1::WorkflowAgentMessage {
role: value.role,
text: value.text.map(to_wire_workflow_text),
metadata: value.metadata.map(to_wire_struct),
}
}
pub(crate) fn from_wire_workflow_agent_message(
value: v1::WorkflowAgentMessage,
) -> WorkflowAgentMessage {
WorkflowAgentMessage {
role: value.role,
text: value.text.map(from_wire_workflow_text),
metadata: value.metadata.map(from_wire_struct),
}
}
pub(crate) fn to_wire_workflow_array(value: WorkflowArray) -> v1::WorkflowArray {
v1::WorkflowArray {
values: value
.values
.into_iter()
.map(to_wire_workflow_value)
.collect(),
}
}
pub(crate) fn from_wire_workflow_array(value: v1::WorkflowArray) -> WorkflowArray {
WorkflowArray {
values: value
.values
.into_iter()
.map(from_wire_workflow_value)
.collect(),
}
}
pub(crate) fn from_wire_workflow_definition(value: v1::WorkflowDefinition) -> WorkflowDefinition {
WorkflowDefinition {
id: value.id,
generation: value.generation,
target: value.target.map(from_wire_bound_workflow_target),
activations: value
.activations
.into_iter()
.map(from_wire_workflow_activation)
.collect(),
paused: value.paused,
created_by_subject_id: value.created_by_subject_id,
created_at: value.created_at.map(from_wire_timestamp),
updated_at: value.updated_at.map(from_wire_timestamp),
provider_name: value.provider_name,
run_as: value.run_as.map(from_wire_subject_context),
}
}
pub(crate) fn to_wire_workflow_definition_spec(
value: WorkflowDefinitionSpec,
) -> v1::WorkflowDefinitionSpec {
v1::WorkflowDefinitionSpec {
id: value.id,
target: value.target.map(to_wire_bound_workflow_target),
activations: value
.activations
.into_iter()
.map(to_wire_workflow_activation)
.collect(),
paused: value.paused,
run_as: value.run_as.map(to_wire_subject_context),
}
}
pub(crate) fn to_wire_workflow_event(value: WorkflowEvent) -> v1::WorkflowEvent {
v1::WorkflowEvent {
id: value.id,
source: value.source,
spec_version: value.spec_version,
r#type: value.r#type,
subject: value.subject,
time: value.time.map(to_wire_timestamp),
datacontenttype: value.datacontenttype,
data: value.data.map(to_wire_struct),
extensions: value
.extensions
.into_iter()
.map(|(key, item)| (key, to_wire_value(item)))
.collect(),
}
}
pub(crate) fn from_wire_workflow_event(value: v1::WorkflowEvent) -> WorkflowEvent {
WorkflowEvent {
id: value.id,
source: value.source,
spec_version: value.spec_version,
r#type: value.r#type,
subject: value.subject,
time: value.time.map(from_wire_timestamp),
datacontenttype: value.datacontenttype,
data: value.data.map(from_wire_struct),
extensions: value
.extensions
.into_iter()
.map(|(key, item)| (key, from_wire_value(item)))
.collect(),
}
}
pub(crate) fn to_wire_workflow_event_activation(
value: WorkflowEventActivation,
) -> v1::WorkflowEventActivation {
v1::WorkflowEventActivation {
r#match: value.r#match.map(to_wire_workflow_event_match),
}
}
pub(crate) fn from_wire_workflow_event_activation(
value: v1::WorkflowEventActivation,
) -> WorkflowEventActivation {
WorkflowEventActivation {
r#match: value.r#match.map(from_wire_workflow_event_match),
}
}
pub(crate) fn to_wire_workflow_event_match(value: WorkflowEventMatch) -> v1::WorkflowEventMatch {
v1::WorkflowEventMatch {
r#type: value.r#type,
source: value.source,
subject: value.subject,
}
}
pub(crate) fn from_wire_workflow_event_match(value: v1::WorkflowEventMatch) -> WorkflowEventMatch {
WorkflowEventMatch {
r#type: value.r#type,
source: value.source,
subject: value.subject,
}
}
pub(crate) fn from_wire_workflow_event_trigger_invocation(
value: v1::WorkflowEventTriggerInvocation,
) -> WorkflowEventTriggerInvocation {
WorkflowEventTriggerInvocation {
activation_id: value.activation_id,
event: value.event.map(from_wire_workflow_event),
}
}
pub(crate) fn from_wire_workflow_manual_trigger(
_value: v1::WorkflowManualTrigger,
) -> WorkflowManualTrigger {
WorkflowManualTrigger {}
}
pub(crate) fn to_wire_workflow_object(value: WorkflowObject) -> v1::WorkflowObject {
v1::WorkflowObject {
fields: value
.fields
.into_iter()
.map(|(key, item)| (key, to_wire_workflow_value(item)))
.collect(),
}
}
pub(crate) fn from_wire_workflow_object(value: v1::WorkflowObject) -> WorkflowObject {
WorkflowObject {
fields: value
.fields
.into_iter()
.map(|(key, item)| (key, from_wire_workflow_value(item)))
.collect(),
}
}
pub(crate) fn to_wire_workflow_path_source(value: WorkflowPathSource) -> v1::WorkflowPathSource {
v1::WorkflowPathSource { path: value.path }
}
pub(crate) fn from_wire_workflow_path_source(value: v1::WorkflowPathSource) -> WorkflowPathSource {
WorkflowPathSource { path: value.path }
}
pub(crate) fn from_wire_workflow_run(value: v1::WorkflowRun) -> WorkflowRun {
WorkflowRun {
id: value.id,
status: value.status,
target: value.target.map(from_wire_bound_workflow_target),
trigger: value.trigger.map(from_wire_workflow_run_trigger),
created_at: value.created_at.map(from_wire_timestamp),
started_at: value.started_at.map(from_wire_timestamp),
completed_at: value.completed_at.map(from_wire_timestamp),
status_message: value.status_message,
output: value.output.map(from_wire_value),
created_by_subject_id: value.created_by_subject_id,
workflow_key: value.workflow_key,
provider_name: value.provider_name,
definition_id: value.definition_id,
run_as: value.run_as.map(from_wire_subject_context),
input: value.input.map(from_wire_struct),
definition_generation: value.definition_generation,
current_step_id: value.current_step_id,
steps: value
.steps
.into_iter()
.map(from_wire_workflow_step_execution)
.collect(),
}
}
pub(crate) fn from_wire_workflow_run_event(value: v1::WorkflowRunEvent) -> WorkflowRunEvent {
WorkflowRunEvent {
id: value.id,
run_id: value.run_id,
step_id: value.step_id,
r#type: value.r#type,
data: value.data.map(from_wire_struct),
created_at: value.created_at.map(from_wire_timestamp),
}
}
pub(crate) fn from_wire_workflow_run_trigger(value: v1::WorkflowRunTrigger) -> WorkflowRunTrigger {
WorkflowRunTrigger {
kind: value.kind.map(from_wire_workflow_run_trigger_kind),
}
}
pub(crate) fn from_wire_workflow_run_trigger_kind(
value: v1::workflow_run_trigger::Kind,
) -> WorkflowRunTriggerKind {
match value {
v1::workflow_run_trigger::Kind::Manual(value) => {
WorkflowRunTriggerKind::Manual(from_wire_workflow_manual_trigger(value))
}
v1::workflow_run_trigger::Kind::Schedule(value) => {
WorkflowRunTriggerKind::Schedule(from_wire_workflow_schedule_trigger(value))
}
v1::workflow_run_trigger::Kind::Event(value) => {
WorkflowRunTriggerKind::Event(from_wire_workflow_event_trigger_invocation(value))
}
}
}
pub(crate) fn to_wire_workflow_schedule_activation(
value: WorkflowScheduleActivation,
) -> v1::WorkflowScheduleActivation {
v1::WorkflowScheduleActivation {
cron: value.cron,
timezone: value.timezone,
}
}
pub(crate) fn from_wire_workflow_schedule_activation(
value: v1::WorkflowScheduleActivation,
) -> WorkflowScheduleActivation {
WorkflowScheduleActivation {
cron: value.cron,
timezone: value.timezone,
}
}
pub(crate) fn from_wire_workflow_schedule_trigger(
value: v1::WorkflowScheduleTrigger,
) -> WorkflowScheduleTrigger {
WorkflowScheduleTrigger {
activation_id: value.activation_id,
scheduled_for: value.scheduled_for.map(from_wire_timestamp),
}
}
pub(crate) fn to_wire_workflow_signal(value: WorkflowSignal) -> v1::WorkflowSignal {
v1::WorkflowSignal {
id: value.id,
name: value.name,
payload: value.payload.map(to_wire_struct),
metadata: value.metadata.map(to_wire_struct),
created_by_subject_id: value.created_by_subject_id,
created_at: value.created_at.map(to_wire_timestamp),
idempotency_key: value.idempotency_key,
sequence: value.sequence,
}
}
pub(crate) fn from_wire_workflow_signal(value: v1::WorkflowSignal) -> WorkflowSignal {
WorkflowSignal {
id: value.id,
name: value.name,
payload: value.payload.map(from_wire_struct),
metadata: value.metadata.map(from_wire_struct),
created_by_subject_id: value.created_by_subject_id,
created_at: value.created_at.map(from_wire_timestamp),
idempotency_key: value.idempotency_key,
sequence: value.sequence,
}
}
pub(crate) fn to_wire_workflow_step(value: WorkflowStep) -> v1::WorkflowStep {
v1::WorkflowStep {
id: value.id,
inputs: value
.inputs
.into_iter()
.map(|(key, item)| (key, to_wire_workflow_value(item)))
.collect(),
when: value.when.map(to_wire_workflow_step_when),
timeout_seconds: value.timeout_seconds,
metadata: value.metadata.map(to_wire_struct),
action: value.action.map(to_wire_workflow_step_action),
}
}
pub(crate) fn from_wire_workflow_step(value: v1::WorkflowStep) -> WorkflowStep {
WorkflowStep {
id: value.id,
inputs: value
.inputs
.into_iter()
.map(|(key, item)| (key, from_wire_workflow_value(item)))
.collect(),
when: value.when.map(from_wire_workflow_step_when),
timeout_seconds: value.timeout_seconds,
metadata: value.metadata.map(from_wire_struct),
action: value.action.map(from_wire_workflow_step_action),
}
}
pub(crate) fn to_wire_workflow_step_action(value: WorkflowStepAction) -> v1::workflow_step::Action {
match value {
WorkflowStepAction::App(value) => {
v1::workflow_step::Action::App(to_wire_workflow_step_app_call(value))
}
WorkflowStepAction::Agent(value) => {
v1::workflow_step::Action::Agent(to_wire_workflow_step_agent_turn(value))
}
}
}
pub(crate) fn from_wire_workflow_step_action(
value: v1::workflow_step::Action,
) -> WorkflowStepAction {
match value {
v1::workflow_step::Action::App(value) => {
WorkflowStepAction::App(from_wire_workflow_step_app_call(value))
}
v1::workflow_step::Action::Agent(value) => {
WorkflowStepAction::Agent(from_wire_workflow_step_agent_turn(value))
}
}
}
pub(crate) fn to_wire_workflow_step_agent_turn(
value: WorkflowStepAgentTurn,
) -> v1::WorkflowStepAgentTurn {
v1::WorkflowStepAgentTurn {
provider: value.provider,
model: value.model,
session_key: value.session_key,
prompt: value.prompt.map(to_wire_workflow_text),
messages: value
.messages
.into_iter()
.map(to_wire_workflow_agent_message)
.collect(),
tools: value
.tools
.into_iter()
.map(to_wire_agent_tool_ref)
.collect(),
output: value.output.map(to_wire_agent_output),
model_options: value.model_options.map(to_wire_struct),
}
}
pub(crate) fn from_wire_workflow_step_agent_turn(
value: v1::WorkflowStepAgentTurn,
) -> WorkflowStepAgentTurn {
WorkflowStepAgentTurn {
provider: value.provider,
model: value.model,
session_key: value.session_key,
prompt: value.prompt.map(from_wire_workflow_text),
messages: value
.messages
.into_iter()
.map(from_wire_workflow_agent_message)
.collect(),
tools: value
.tools
.into_iter()
.map(from_wire_agent_tool_ref)
.collect(),
output: value.output.map(from_wire_agent_output),
model_options: value.model_options.map(from_wire_struct),
}
}
pub(crate) fn to_wire_workflow_step_app_call(
value: WorkflowStepAppCall,
) -> v1::WorkflowStepAppCall {
v1::WorkflowStepAppCall {
name: value.name,
operation: value.operation,
input: value.input.map(to_wire_workflow_value),
connection: value.connection,
instance: value.instance,
credential_mode: value.credential_mode,
}
}
pub(crate) fn from_wire_workflow_step_app_call(
value: v1::WorkflowStepAppCall,
) -> WorkflowStepAppCall {
WorkflowStepAppCall {
name: value.name,
operation: value.operation,
input: value.input.map(from_wire_workflow_value),
connection: value.connection,
instance: value.instance,
credential_mode: value.credential_mode,
}
}
pub(crate) fn from_wire_workflow_step_attempt(
value: v1::WorkflowStepAttempt,
) -> WorkflowStepAttempt {
WorkflowStepAttempt {
id: value.id,
status: value.status,
idempotency_key: value.idempotency_key,
input: value.input.map(from_wire_value),
output: value.output.map(from_wire_value),
status_message: value.status_message,
started_at: value.started_at.map(from_wire_timestamp),
completed_at: value.completed_at.map(from_wire_timestamp),
}
}
pub(crate) fn from_wire_workflow_step_execution(
value: v1::WorkflowStepExecution,
) -> WorkflowStepExecution {
WorkflowStepExecution {
step_id: value.step_id,
status: value.status,
attempts: value
.attempts
.into_iter()
.map(from_wire_workflow_step_attempt)
.collect(),
input: value.input.map(from_wire_value),
output: value.output.map(from_wire_value),
status_message: value.status_message,
skip_reason: value.skip_reason,
started_at: value.started_at.map(from_wire_timestamp),
completed_at: value.completed_at.map(from_wire_timestamp),
}
}
pub(crate) fn to_wire_workflow_step_input_source(
value: WorkflowStepInputSource,
) -> v1::WorkflowStepInputSource {
v1::WorkflowStepInputSource {
step_id: value.step_id,
path: value.path,
}
}
pub(crate) fn from_wire_workflow_step_input_source(
value: v1::WorkflowStepInputSource,
) -> WorkflowStepInputSource {
WorkflowStepInputSource {
step_id: value.step_id,
path: value.path,
}
}
pub(crate) fn to_wire_workflow_step_output_source(
value: WorkflowStepOutputSource,
) -> v1::WorkflowStepOutputSource {
v1::WorkflowStepOutputSource {
step_id: value.step_id,
path: value.path,
}
}
pub(crate) fn from_wire_workflow_step_output_source(
value: v1::WorkflowStepOutputSource,
) -> WorkflowStepOutputSource {
WorkflowStepOutputSource {
step_id: value.step_id,
path: value.path,
}
}
pub(crate) fn to_wire_workflow_step_when(value: WorkflowStepWhen) -> v1::WorkflowStepWhen {
v1::WorkflowStepWhen {
value: value.value.map(to_wire_workflow_value),
equals: value.equals.map(to_wire_value),
}
}
pub(crate) fn from_wire_workflow_step_when(value: v1::WorkflowStepWhen) -> WorkflowStepWhen {
WorkflowStepWhen {
value: value.value.map(from_wire_workflow_value),
equals: value.equals.map(from_wire_value),
}
}
pub(crate) fn to_wire_workflow_text(value: WorkflowText) -> v1::WorkflowText {
v1::WorkflowText {
template: value.template,
}
}
pub(crate) fn from_wire_workflow_text(value: v1::WorkflowText) -> WorkflowText {
WorkflowText {
template: value.template,
}
}
pub(crate) fn to_wire_workflow_value(value: WorkflowValue) -> v1::WorkflowValue {
v1::WorkflowValue {
kind: value.kind.map(to_wire_workflow_value_kind),
}
}
pub(crate) fn from_wire_workflow_value(value: v1::WorkflowValue) -> WorkflowValue {
WorkflowValue {
kind: value.kind.map(from_wire_workflow_value_kind),
}
}
pub(crate) fn to_wire_workflow_value_kind(value: WorkflowValueKind) -> v1::workflow_value::Kind {
match value {
WorkflowValueKind::Literal(value) => {
v1::workflow_value::Kind::Literal(to_wire_value(value))
}
WorkflowValueKind::Object(value) => {
v1::workflow_value::Kind::Object(to_wire_workflow_object(value))
}
WorkflowValueKind::Array(value) => {
v1::workflow_value::Kind::Array(to_wire_workflow_array(value))
}
WorkflowValueKind::Template(value) => {
v1::workflow_value::Kind::Template(to_wire_workflow_text(value))
}
WorkflowValueKind::Input(value) => {
v1::workflow_value::Kind::Input(to_wire_workflow_path_source(value))
}
WorkflowValueKind::Signal(value) => {
v1::workflow_value::Kind::Signal(to_wire_workflow_path_source(value))
}
WorkflowValueKind::StepOutput(value) => {
v1::workflow_value::Kind::StepOutput(to_wire_workflow_step_output_source(value))
}
WorkflowValueKind::StepInput(value) => {
v1::workflow_value::Kind::StepInput(to_wire_workflow_step_input_source(value))
}
}
}
pub(crate) fn from_wire_workflow_value_kind(value: v1::workflow_value::Kind) -> WorkflowValueKind {
match value {
v1::workflow_value::Kind::Literal(value) => {
WorkflowValueKind::Literal(from_wire_value(value))
}
v1::workflow_value::Kind::Object(value) => {
WorkflowValueKind::Object(from_wire_workflow_object(value))
}
v1::workflow_value::Kind::Array(value) => {
WorkflowValueKind::Array(from_wire_workflow_array(value))
}
v1::workflow_value::Kind::Template(value) => {
WorkflowValueKind::Template(from_wire_workflow_text(value))
}
v1::workflow_value::Kind::Input(value) => {
WorkflowValueKind::Input(from_wire_workflow_path_source(value))
}
v1::workflow_value::Kind::Signal(value) => {
WorkflowValueKind::Signal(from_wire_workflow_path_source(value))
}
v1::workflow_value::Kind::StepOutput(value) => {
WorkflowValueKind::StepOutput(from_wire_workflow_step_output_source(value))
}
v1::workflow_value::Kind::StepInput(value) => {
WorkflowValueKind::StepInput(from_wire_workflow_step_input_source(value))
}
}
}