- ✅ 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
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
export const CallableInstance =
|
|
/**
|
|
* @type {new <Parameters extends Array<unknown>, Result>(property: string | symbol) => (...parameters: Parameters) => Result}
|
|
*/
|
|
(
|
|
/** @type {unknown} */
|
|
(
|
|
/**
|
|
* @this {Function}
|
|
* @param {string | symbol} property
|
|
* @returns {(...parameters: Array<unknown>) => unknown}
|
|
*/
|
|
function (property) {
|
|
const self = this
|
|
const constr = self.constructor
|
|
const proto = /** @type {Record<string | symbol, Function>} */ (
|
|
// Prototypes do exist.
|
|
// type-coverage:ignore-next-line
|
|
constr.prototype
|
|
)
|
|
const value = proto[property]
|
|
/** @type {(...parameters: Array<unknown>) => unknown} */
|
|
const apply = function () {
|
|
return value.apply(apply, arguments)
|
|
}
|
|
|
|
Object.setPrototypeOf(apply, proto)
|
|
|
|
// Not needed for us in `unified`: we only call this on the `copy`
|
|
// function,
|
|
// and we don't need to add its fields (`length`, `name`)
|
|
// over.
|
|
// See also: GH-246.
|
|
// const names = Object.getOwnPropertyNames(value)
|
|
//
|
|
// for (const p of names) {
|
|
// const descriptor = Object.getOwnPropertyDescriptor(value, p)
|
|
// if (descriptor) Object.defineProperty(apply, p, descriptor)
|
|
// }
|
|
|
|
return apply
|
|
}
|
|
)
|
|
)
|