- ✅ Ticket 1.1: Estructura Clean Architecture en backend - ✅ Ticket 1.2: Schemas Zod compartidos - ✅ Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares) - ✅ Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares) - ✅ Ticket 1.5: Eliminación de duplicidades (~50 líneas) Cambios principales: - Creada estructura Clean Architecture en backend/src/ - Schemas Zod compartidos en backend/src/shared/schemas/ - Refactorización modular de drugs y procedures - Utilidades genéricas en src/utils/ (filter, validation) - Eliminados scripts obsoletos y documentación antigua - Corregidos errores: QueryClient, import test-error-handling - Build verificado y funcionando correctamente
45 lines
978 B
JavaScript
45 lines
978 B
JavaScript
/**
|
|
* @import {Element, Parents} from 'hast'
|
|
*/
|
|
|
|
/**
|
|
* @callback OmitHandle
|
|
* Check if a tag can be omitted.
|
|
* @param {Element} element
|
|
* Element to check.
|
|
* @param {number | undefined} index
|
|
* Index of element in parent.
|
|
* @param {Parents | undefined} parent
|
|
* Parent of element.
|
|
* @returns {boolean}
|
|
* Whether to omit a tag.
|
|
*
|
|
*/
|
|
|
|
const own = {}.hasOwnProperty
|
|
|
|
/**
|
|
* Factory to check if a given node can have a tag omitted.
|
|
*
|
|
* @param {Record<string, OmitHandle>} handlers
|
|
* Omission handlers, where each key is a tag name, and each value is the
|
|
* corresponding handler.
|
|
* @returns {OmitHandle}
|
|
* Whether to omit a tag of an element.
|
|
*/
|
|
export function omission(handlers) {
|
|
return omit
|
|
|
|
/**
|
|
* Check if a given node can have a tag omitted.
|
|
*
|
|
* @type {OmitHandle}
|
|
*/
|
|
function omit(node, index, parent) {
|
|
return (
|
|
own.call(handlers, node.tagName) &&
|
|
handlers[node.tagName](node, index, parent)
|
|
)
|
|
}
|
|
}
|