import type { Structure } from "@/payload-types"; export type ProductionDefaults = { readonly productionInputs: NonNullable; readonly productionOutputs: NonNullable; }; export function productionDefaultsFromBlueprint(blueprint: Structure): ProductionDefaults { return { productionInputs: (blueprint.productionInputs ?? []).map((input) => ({ resource: typeof input.resource === "object" ? input.resource.id : input.resource, amountPerHour: input.amountPerHour ?? 0, })), productionOutputs: (blueprint.productionOutputs ?? []).map((output) => ({ resource: typeof output.resource === "object" ? output.resource.id : output.resource, amountPerHour: output.amountPerHour ?? 0, })), }; }