Architecture review (hai-architecture / APoSD) of the shipped redesign found one structural smell: the shared lib/ layer imported the release manifest from components/ — data in the presentation layer, dependency pointing the wrong way. - move components/release-links.generated.ts -> lib/; update the four importers and the README. lib/ no longer imports from components/. - downloads.ts: reuse PlatformDownload["id"] instead of re-declaring the union. No behavior change (download counter + tracked hrefs identical); build + e2e 12/12.
29 lines
949 B
TypeScript
29 lines
949 B
TypeScript
import { platformDownloads, type PlatformDownload, type PlatformDownloadAsset } from "./release-links.generated";
|
|
|
|
export const DOWNLOAD_COUNT_SEED = 13674;
|
|
export const DOWNLOAD_DEDUP_WINDOW_HOURS = 24;
|
|
export const DOWNLOAD_DEDUP_WINDOW_MS = DOWNLOAD_DEDUP_WINDOW_HOURS * 60 * 60 * 1000;
|
|
|
|
export type ReleaseDownloadAsset = PlatformDownloadAsset & {
|
|
platformId: PlatformDownload["id"];
|
|
platformTitle: string;
|
|
};
|
|
|
|
export const downloadAssets: ReleaseDownloadAsset[] = platformDownloads.flatMap((platform) =>
|
|
platform.assets.map((asset) => ({
|
|
...asset,
|
|
platformId: platform.id,
|
|
platformTitle: platform.title,
|
|
})),
|
|
);
|
|
|
|
const downloadAssetMap = new Map(downloadAssets.map((asset) => [asset.id, asset]));
|
|
|
|
export function getDownloadAsset(assetId: string) {
|
|
return downloadAssetMap.get(assetId) ?? null;
|
|
}
|
|
|
|
export function getTrackedDownloadHref(assetId: string) {
|
|
return `/api/download?asset=${encodeURIComponent(assetId)}`;
|
|
}
|