import { createPluginModule, modelTransformerCompilerSpec, } from '@baseplate-dev/project-builder-lib';
import { fileDataFieldGenerator } from '#src/generators/fastify/index.js';
function buildFileTransformerCompiler() {
    return {
        name: 'file',
        compileField(definition, { model, definitionContainer }) {
            const { fileRelationRef, categoryRef } = definition;
            const foreignRelation = model.model.relations.find((relation) => relation.id === fileRelationRef);
            if (!foreignRelation) {
                throw new Error(`Could not find relation ${fileRelationRef} for file field`);
            }
            return fileDataFieldGenerator({
                modelName: model.name,
                relationName: foreignRelation.name,
                category: definitionContainer.nameFromId(categoryRef),
                featureId: model.featureRef,
            });
        },
    };
}
export default createPluginModule({
    name: 'node',
    dependencies: {
        transformerCompiler: modelTransformerCompilerSpec,
    },
    initialize: ({ transformerCompiler }) => {
        transformerCompiler.transformers.add(buildFileTransformerCompiler());
    },
});
//# sourceMappingURL=node.js.map