Fix inventoryService

The reinterpret casts are needed as toJSON can no longer infer that the virtual 'ItemId' is being added to the resulting object, causing a type error about the database types being incompatible with the client types.
This commit is contained in:
Sainan 2024-12-15 21:47:41 +01:00
parent 87030c1b0c
commit b491cf81b6

View File

@ -369,7 +369,7 @@ export const addPowerSuit = async (powersuitName: string, accountId: string): Pr
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 }); const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 });
const changedInventory = await inventory.save(); const changedInventory = await inventory.save();
return changedInventory.Suits[suitIndex - 1].toJSON(); return changedInventory.Suits[suitIndex - 1].toJSON() as object as IEquipmentClient;
}; };
export const addMechSuit = async (mechsuitName: string, accountId: string) => { export const addMechSuit = async (mechsuitName: string, accountId: string) => {
@ -527,7 +527,7 @@ export const addEquipment = async (
}); });
const changedInventory = await inventory.save(); const changedInventory = await inventory.save();
return changedInventory[category][index - 1].toJSON(); return changedInventory[category][index - 1].toJSON() as object as IEquipmentClient;
}; };
export const addCustomization = async (customizatonName: string, accountId: string): Promise<IFlavourItem> => { export const addCustomization = async (customizatonName: string, accountId: string): Promise<IFlavourItem> => {
@ -541,7 +541,7 @@ export const addSkin = async (typeName: string, accountId: string): Promise<IWea
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
const index = inventory.WeaponSkins.push({ ItemType: typeName }) - 1; const index = inventory.WeaponSkins.push({ ItemType: typeName }) - 1;
const changedInventory = await inventory.save(); const changedInventory = await inventory.save();
return changedInventory.WeaponSkins[index].toJSON(); return changedInventory.WeaponSkins[index].toJSON() as object as IWeaponSkinClient;
}; };
const addGearExpByCategory = ( const addGearExpByCategory = (