- ✅ 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
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import validate from './validate.js';
|
|
const byteToHex = [];
|
|
for (let i = 0; i < 256; ++i) {
|
|
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
}
|
|
export function unsafeStringify(arr, offset = 0) {
|
|
return (byteToHex[arr[offset + 0]] +
|
|
byteToHex[arr[offset + 1]] +
|
|
byteToHex[arr[offset + 2]] +
|
|
byteToHex[arr[offset + 3]] +
|
|
'-' +
|
|
byteToHex[arr[offset + 4]] +
|
|
byteToHex[arr[offset + 5]] +
|
|
'-' +
|
|
byteToHex[arr[offset + 6]] +
|
|
byteToHex[arr[offset + 7]] +
|
|
'-' +
|
|
byteToHex[arr[offset + 8]] +
|
|
byteToHex[arr[offset + 9]] +
|
|
'-' +
|
|
byteToHex[arr[offset + 10]] +
|
|
byteToHex[arr[offset + 11]] +
|
|
byteToHex[arr[offset + 12]] +
|
|
byteToHex[arr[offset + 13]] +
|
|
byteToHex[arr[offset + 14]] +
|
|
byteToHex[arr[offset + 15]]).toLowerCase();
|
|
}
|
|
function stringify(arr, offset = 0) {
|
|
const uuid = unsafeStringify(arr, offset);
|
|
if (!validate(uuid)) {
|
|
throw TypeError('Stringified UUID is invalid');
|
|
}
|
|
return uuid;
|
|
}
|
|
export default stringify;
|