@bernierllc/temporal-workflow-ui
Version:
Thin domain-specific wrapper around @bernierllc/generic-workflow-ui for Temporal workflows
76 lines (74 loc) • 2.28 kB
JavaScript
;
/*
Copyright (c) 2025 Bernier LLC
This file is licensed to the client under a limited-use license.
The client may use and modify this code *only within the scope of the project it was delivered for*.
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.temporalToGeneric = temporalToGeneric;
/**
* Convert Temporal workflow to Generic workflow
*
* @param temporal - Temporal workflow definition
* @returns Generic workflow definition
*/
function temporalToGeneric(temporal) {
return {
id: temporal.id,
name: temporal.name,
description: temporal.description,
stages: temporal.stages.map(temporalStageToGeneric),
transitions: temporal.transitions.map(temporalTransitionToGeneric),
metadata: {
...temporal.metadata,
temporal: {
defaultTaskQueue: temporal.defaultTaskQueue,
workflowTimeout: temporal.workflowTimeout,
searchAttributes: temporal.searchAttributes,
workQueues: temporal.workQueues,
signals: temporal.signals,
queries: temporal.queries,
},
},
};
}
/**
* Convert Temporal stage to Generic stage
*
* @param stage - Temporal workflow stage
* @returns Generic stage
*/
function temporalStageToGeneric(stage) {
return {
id: stage.id,
name: stage.name,
description: stage.description,
order: stage.order,
metadata: {
type: stage.type,
temporal: stage.metadata,
icon: stage.icon,
color: stage.color,
},
};
}
/**
* Convert Temporal transition to Generic transition
*
* @param transition - Temporal workflow transition
* @returns Generic transition
*/
function temporalTransitionToGeneric(transition) {
return {
id: transition.id,
from: transition.from,
to: transition.to,
name: transition.name,
description: transition.description,
metadata: {
condition: transition.condition,
temporal: transition.metadata,
},
};
}