- ✅ 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
68 lines
1.5 KiB
JavaScript
68 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
const types = require('../../tokenizer/types.cjs');
|
|
|
|
const name = 'FeatureFunction';
|
|
const structure = {
|
|
kind: String,
|
|
feature: String,
|
|
value: ['Declaration', 'Selector']
|
|
};
|
|
|
|
function getFeatureParser(kind, name) {
|
|
const featuresOfKind = this.features[kind] || {};
|
|
const parser = featuresOfKind[name];
|
|
|
|
if (typeof parser !== 'function') {
|
|
this.error(`Unknown feature ${name}()`);
|
|
}
|
|
|
|
return parser;
|
|
}
|
|
|
|
function parse(kind = 'unknown') {
|
|
const start = this.tokenStart;
|
|
const functionName = this.consumeFunctionName();
|
|
const valueParser = getFeatureParser.call(this, kind, functionName.toLowerCase());
|
|
|
|
this.skipSC();
|
|
|
|
const value = this.parseWithFallback(
|
|
() => {
|
|
const startValueToken = this.tokenIndex;
|
|
const value = valueParser.call(this);
|
|
|
|
if (this.eof === false &&
|
|
this.isBalanceEdge(startValueToken) === false) {
|
|
this.error();
|
|
}
|
|
|
|
return value;
|
|
},
|
|
() => this.Raw(null, false)
|
|
);
|
|
|
|
if (!this.eof) {
|
|
this.eat(types.RightParenthesis);
|
|
}
|
|
|
|
return {
|
|
type: 'FeatureFunction',
|
|
loc: this.getLocation(start, this.tokenStart),
|
|
kind,
|
|
feature: functionName,
|
|
value
|
|
};
|
|
}
|
|
|
|
function generate(node) {
|
|
this.token(types.Function, node.feature + '(');
|
|
this.node(node.value);
|
|
this.token(types.RightParenthesis, ')');
|
|
}
|
|
|
|
exports.generate = generate;
|
|
exports.name = name;
|
|
exports.parse = parse;
|
|
exports.structure = structure;
|