@fromsvenwithlove/devops-issues-cli
Version:
AI-powered CLI tool and library for Azure DevOps work item management with Claude agents
53 lines (46 loc) • 1.44 kB
JavaScript
/**
* Work item type hierarchy and utilities
*/
// Mapping from parent work item type to child work item type
const PARENT_TO_CHILD_TYPE_MAP = {
'Epic': 'User Story',
'Feature': 'User Story',
'User Story': 'Task',
'Task': 'Task',
'Bug': 'Task'
};
// Default work item type if parent type is not recognized
const DEFAULT_CHILD_TYPE = 'Task';
/**
* Determines the appropriate child work item type based on parent type
* @param {string} parentType - The work item type of the parent
* @returns {string} The appropriate child work item type
*/
export function getChildWorkItemType(parentType) {
if (!parentType) {
return DEFAULT_CHILD_TYPE;
}
return PARENT_TO_CHILD_TYPE_MAP[parentType] || DEFAULT_CHILD_TYPE;
}
/**
* Validates if a parent type can have children
* @param {string} parentType - The work item type to check
* @returns {boolean} True if the type can have children
*/
export function canHaveChildren(parentType) {
return Object.prototype.hasOwnProperty.call(PARENT_TO_CHILD_TYPE_MAP, parentType);
}
/**
* Gets all supported parent types
* @returns {string[]} Array of parent types that can have children
*/
export function getSupportedParentTypes() {
return Object.keys(PARENT_TO_CHILD_TYPE_MAP);
}
/**
* Gets the type hierarchy information
* @returns {Object} The complete parent to child mapping
*/
export function getTypeHierarchy() {
return { ...PARENT_TO_CHILD_TYPE_MAP };
}