Refactor type-safe constants and extract utility helpers
This commit is contained in:
@@ -10,6 +10,9 @@ import {
|
||||
platforms,
|
||||
type PlatformContext,
|
||||
type PlatformAdaptor,
|
||||
type PublishInput,
|
||||
PublishResultSchema,
|
||||
ProgressEventSchema,
|
||||
} from "./publish.schemas";
|
||||
import { publishModrinthVersion } from "./platforms/modrinth";
|
||||
import { publishCurseForgeVersion } from "./platforms/curseforge";
|
||||
@@ -44,7 +47,7 @@ const ee = new EventEmitter();
|
||||
|
||||
async function runPlatform(
|
||||
platform: typeof platforms[number],
|
||||
mcVersions: { mc_version: string }[],
|
||||
mcVersions: PublishInput["mcVersions"][keyof PublishInput["mcVersions"]],
|
||||
ctx: PlatformContext,
|
||||
): Promise<PlatformResult> {
|
||||
const result: PlatformResult = { success: 0, fail: 0, errors: [] };
|
||||
@@ -146,14 +149,14 @@ export const appRouter = t.router({
|
||||
}
|
||||
}));
|
||||
|
||||
return Object.fromEntries(results.map(result => [result.platform, result.result]));
|
||||
return PublishResultSchema.parse(Object.fromEntries(results.map(result => [result.platform, result.result])));
|
||||
}),
|
||||
|
||||
progress: t.procedure.subscription(async function* (opts) {
|
||||
for await (const [data] of on(ee, "progress", {
|
||||
signal: opts.signal,
|
||||
})) {
|
||||
yield data as ProgressEvent;
|
||||
yield ProgressEventSchema.parse(data);
|
||||
}
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user