- ✅ 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
88 lines
2.1 KiB
JavaScript
88 lines
2.1 KiB
JavaScript
/**
|
|
* @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext
|
|
* @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
|
|
* @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle
|
|
*
|
|
* @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle
|
|
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
|
|
*
|
|
* @typedef {import('../index.js').MdxjsEsm} MdxjsEsm
|
|
*/
|
|
|
|
// To do: next major: expose functions.
|
|
import {ok as assert} from 'devlop'
|
|
|
|
/**
|
|
* Create an extension for `mdast-util-from-markdown` to enable MDX.js ESM in
|
|
* markdown.
|
|
*
|
|
* When using the micromark syntax extension with `addResult`, nodes will have
|
|
* a `data.estree` field set to an ESTree [`Program`][program] node.
|
|
*
|
|
* @returns {FromMarkdownExtension}
|
|
* Extension for `mdast-util-from-markdown` to enable MDX.js ESM.
|
|
*/
|
|
export function mdxjsEsmFromMarkdown() {
|
|
return {
|
|
enter: {mdxjsEsm: enterMdxjsEsm},
|
|
exit: {mdxjsEsm: exitMdxjsEsm, mdxjsEsmData: exitMdxjsEsmData}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create an extension for `mdast-util-to-markdown` to enable MDX.js ESM in
|
|
* markdown.
|
|
*
|
|
* @returns {ToMarkdownExtension}
|
|
* Extension for `mdast-util-to-markdown` to enable MDX.js ESM.
|
|
*/
|
|
export function mdxjsEsmToMarkdown() {
|
|
return {handlers: {mdxjsEsm: handleMdxjsEsm}}
|
|
}
|
|
|
|
/**
|
|
* @this {CompileContext}
|
|
* @type {FromMarkdownHandle}
|
|
*/
|
|
function enterMdxjsEsm(token) {
|
|
this.enter({type: 'mdxjsEsm', value: ''}, token)
|
|
this.buffer() // Capture EOLs
|
|
}
|
|
|
|
/**
|
|
* @this {CompileContext}
|
|
* @type {FromMarkdownHandle}
|
|
*/
|
|
function exitMdxjsEsm(token) {
|
|
const value = this.resume()
|
|
const node = this.stack[this.stack.length - 1]
|
|
assert(node.type === 'mdxjsEsm')
|
|
|
|
this.exit(token)
|
|
|
|
const estree = token.estree
|
|
|
|
node.value = value
|
|
|
|
if (estree) {
|
|
node.data = {estree}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @this {CompileContext}
|
|
* @type {FromMarkdownHandle}
|
|
*/
|
|
function exitMdxjsEsmData(token) {
|
|
this.config.enter.data.call(this, token)
|
|
this.config.exit.data.call(this, token)
|
|
}
|
|
|
|
/**
|
|
* @type {ToMarkdownHandle}
|
|
* @param {MdxjsEsm} node
|
|
*/
|
|
function handleMdxjsEsm(node) {
|
|
return node.value || ''
|
|
}
|