Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
22 lines
804 B
TypeScript
22 lines
804 B
TypeScript
|
|
|
|
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
|
import type { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
|
import type { CategoryIconViewData } from '@/lib/view-data/CategoryIconViewData';
|
|
import type { GetMediaOutputDTO } from '@/lib/types/generated/GetMediaOutputDTO';
|
|
|
|
export class CategoryIconViewDataBuilder {
|
|
public static build(apiDto: MediaBinaryDTO): CategoryIconViewData {
|
|
// Note: GetMediaOutputDTO from OpenAPI doesn't have buffer,
|
|
// but the implementation expects it for binary data.
|
|
const binaryDto = apiDto as unknown as { buffer?: ArrayBuffer };
|
|
const buffer = binaryDto.buffer;
|
|
|
|
return {
|
|
buffer: buffer ? Buffer.from(buffer).toString('base64') : '',
|
|
contentType: (apiDto as any).contentType,
|
|
};
|
|
}
|
|
}
|
|
|