view data fixes

This commit is contained in:
2026-01-24 00:52:27 +01:00
parent 62e8b768ce
commit ae59df61eb
321 changed files with 1157 additions and 2234 deletions

View File

@@ -1,25 +1,23 @@
/**
* AvatarViewDataBuilder
*
* Transforms MediaBinaryDTO into AvatarViewData for server-side rendering.
* Deterministic; side-effect free; no HTTP calls.
*/
'use client';
import { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
import { AvatarViewData } from '@/lib/view-data/AvatarViewData';
import type { GetMediaOutputDTO } from '@/lib/types/generated/GetMediaOutputDTO';
import type { AvatarViewData } from '@/lib/view-data/AvatarViewData';
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
export class AvatarViewDataBuilder implements ViewDataBuilder<any, any> {
build(input: any): any {
return AvatarViewDataBuilder.build(input);
}
static build(
static build(apiDto: MediaBinaryDTO): AvatarViewData {
export class AvatarViewDataBuilder {
public static build(apiDto: GetMediaOutputDTO): AvatarViewData {
// Note: GetMediaOutputDTO from OpenAPI doesn't have buffer,
// but the implementation expects it for binary data.
// We use type assertion to handle the binary case while keeping the DTO type.
const binaryDto = apiDto as unknown as { buffer?: ArrayBuffer };
const buffer = binaryDto.buffer;
const contentType = apiDto.type;
return {
buffer: Buffer.from(apiDto.buffer).toString('base64'),
contentType: apiDto.contentType,
buffer: buffer ? Buffer.from(buffer).toString('base64') : '',
contentType,
};
}
}
}
AvatarViewDataBuilder satisfies ViewDataBuilder<GetMediaOutputDTO, AvatarViewData>;