Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
20 lines
803 B
TypeScript
20 lines
803 B
TypeScript
import type { Structure } from "@/payload-types";
|
|
|
|
export type ProductionDefaults = {
|
|
readonly productionInputs: NonNullable<Structure["productionInputs"]>;
|
|
readonly productionOutputs: NonNullable<Structure["productionOutputs"]>;
|
|
};
|
|
|
|
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,
|
|
})),
|
|
};
|
|
}
|