refactor(plugin-sdk): add shared helper utilities

This commit is contained in:
Peter Steinberger
2026-02-15 19:35:38 +00:00
parent 108f0ef8c4
commit 80eb91d9e7
5 changed files with 168 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
export type AgentMediaPayload = {
MediaPath?: string;
MediaType?: string;
MediaUrl?: string;
MediaPaths?: string[];
MediaUrls?: string[];
MediaTypes?: string[];
};
export function buildAgentMediaPayload(
mediaList: Array<{ path: string; contentType?: string | null }>,
): AgentMediaPayload {
const first = mediaList[0];
const mediaPaths = mediaList.map((media) => media.path);
const mediaTypes = mediaList.map((media) => media.contentType).filter(Boolean) as string[];
return {
MediaPath: first?.path,
MediaType: first?.contentType ?? undefined,
MediaUrl: first?.path,
MediaPaths: mediaPaths.length > 0 ? mediaPaths : undefined,
MediaUrls: mediaPaths.length > 0 ? mediaPaths : undefined,
MediaTypes: mediaTypes.length > 0 ? mediaTypes : undefined,
};
}