import { registerSerializer } from '../registry.js';
function baseSingle(entity) {
    return {
        type: 'dto',
        slug: entity.slug,
        name: entity.data.name,
        description: entity.data.description ?? null,
        fields: entity.data.fields ?? [],
        examples: entity.data.examples ?? [],
        tags: entity.tags,
    };
}
const dtoSerializer = {
    type: 'dto',
    version: '1.1.0',
    inlineMention: (entity) => ({
        type: 'dto',
        slug: entity.slug,
        label: entity.data.name ?? entity.slug,
        href: `/dtos/${entity.slug}`,
    }),
    singleElement: (entity) => baseSingle(entity),
    elementListItem: (entity) => baseSingle(entity),
    taggedListItem: (entity) => baseSingle(entity),
    detail: (entity, ctx) => {
        const base = baseSingle(entity);
        const endpoints = ctx.reader.findDtoEndpoints(entity.id).map((e) => ({
            endpointSlug: e.endpointSlug,
            method: e.method,
            path: e.path,
            relation: e.relation,
            statusCode: e.statusCode,
        }));
        const references = ctx.reader.findSectionReferences('dto', entity.id).map((r) => ({
            anchor: r.anchor,
            pagePath: r.pagePath,
            headingText: r.headingText,
            relation: r.relation,
        }));
        return {
            ...base,
            endpoints,
            _references: references,
        };
    },
};
registerSerializer(dtoSerializer);
//# sourceMappingURL=dto.js.map