improve: typings

This commit is contained in:
Sainan 2024-06-07 16:20:36 +02:00
parent cbcb845c41
commit 965bfaec6d
4 changed files with 14 additions and 27 deletions

8
package-lock.json generated
View File

@ -13,7 +13,7 @@
"express": "^5.0.0-beta.3", "express": "^5.0.0-beta.3",
"mongoose": "^8.1.1", "mongoose": "^8.1.1",
"warframe-items": "^1.1262.74", "warframe-items": "^1.1262.74",
"warframe-public-export-plus": "^0.2.0", "warframe-public-export-plus": "^0.2.2",
"warframe-riven-info": "^0.1.0", "warframe-riven-info": "^0.1.0",
"winston": "^3.11.0", "winston": "^3.11.0",
"winston-daily-rotate-file": "^4.7.1" "winston-daily-rotate-file": "^4.7.1"
@ -3895,9 +3895,9 @@
} }
}, },
"node_modules/warframe-public-export-plus": { "node_modules/warframe-public-export-plus": {
"version": "0.2.0", "version": "0.2.2",
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.2.0.tgz", "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.2.2.tgz",
"integrity": "sha512-JkTpkOzFWmjaK10H3CphGz4f6IAdH5higF9jyyTBbBD97U21C+3u9OGAoWav5CO8ydR2hLezcyOyRaqBAf4Abg==" "integrity": "sha512-PAsiyiRDqXcsUwZTweihwrSksd+GT3USrbHwS/TrJUC3TqLS0Ng24OfefFKPWOmPfMxDbdkg2zV39uq72iZ/Yg=="
}, },
"node_modules/warframe-riven-info": { "node_modules/warframe-riven-info": {
"version": "0.1.0", "version": "0.1.0",

View File

@ -17,7 +17,7 @@
"express": "^5.0.0-beta.3", "express": "^5.0.0-beta.3",
"mongoose": "^8.1.1", "mongoose": "^8.1.1",
"warframe-items": "^1.1262.74", "warframe-items": "^1.1262.74",
"warframe-public-export-plus": "^0.2.0", "warframe-public-export-plus": "^0.2.2",
"warframe-riven-info": "^0.1.0", "warframe-riven-info": "^0.1.0",
"winston": "^3.11.0", "winston": "^3.11.0",
"winston-daily-rotate-file": "^4.7.1" "winston-daily-rotate-file": "^4.7.1"

View File

@ -1,8 +1,7 @@
import { RequestHandler } from "express"; import { RequestHandler } from "express";
import { MinItem, MinWeapon, warframes, items, getEnglishString } from "@/src/services/itemDataService"; import { MinItem, MinWeapon, warframes, items, getEnglishString } from "@/src/services/itemDataService";
import badItems from "@/static/json/exclude-mods.json"; import badItems from "@/static/json/exclude-mods.json";
import ExportArcanes from "@/node_modules/warframe-public-export-plus/ExportArcanes.json"; import { ExportArcanes, ExportWeapons } from "warframe-public-export-plus";
import ExportWeapons from "@/node_modules/warframe-public-export-plus/ExportWeapons.json";
interface ListedItem { interface ListedItem {
uniqueName: string; uniqueName: string;
@ -32,10 +31,10 @@ const getItemListsController: RequestHandler = (_req, res) => {
warframes: reduceItems(warframes), warframes: reduceItems(warframes),
weapons: Object.entries(ExportWeapons) weapons: Object.entries(ExportWeapons)
.filter( .filter(
([_uniqueName, weapon]: [string, any]) => ([_uniqueName, weapon]) =>
weapon.productCategory !== "OperatorAmps" && weapon.totalDamage !== 0 weapon.productCategory !== "OperatorAmps" && weapon.totalDamage !== 0
) )
.map(([uniqueName, weapon]: [string, any]) => { .map(([uniqueName, weapon]) => {
return { return {
uniqueName, uniqueName,
name: getEnglishString(weapon.name) name: getEnglishString(weapon.name)

View File

@ -2,9 +2,7 @@ import { getIndexAfter } from "@/src/helpers/stringHelpers";
import { logger } from "@/src/utils/logger"; import { logger } from "@/src/utils/logger";
import Items, { Buildable, Category, MinimalItem, Warframe, Weapon } from "warframe-items"; import Items, { Buildable, Category, MinimalItem, Warframe, Weapon } from "warframe-items";
import badItems from "@/static/json/exclude-mods.json"; import badItems from "@/static/json/exclude-mods.json";
import dict_en from "@/node_modules/warframe-public-export-plus/dict.en.json"; import { dict_en, ExportWarframes, ExportWeapons, IPowersuit } from "warframe-public-export-plus";
import ExportWarframes from "@/node_modules/warframe-public-export-plus/ExportWarframes.json";
import ExportWeapons from "@/node_modules/warframe-public-export-plus/ExportWeapons.json";
export type MinWarframe = Omit<Warframe, "patchlogs">; export type MinWarframe = Omit<Warframe, "patchlogs">;
export type MinWeapon = Omit<Weapon, "patchlogs">; export type MinWeapon = Omit<Weapon, "patchlogs">;
@ -36,8 +34,8 @@ export const items: MinItem[] = Array.from(new Items({ category: ["All"] }) as M
return next; return next;
}); });
export const getWeaponType = (weaponName: string) => { export const getWeaponType = (weaponName: string): WeaponTypeInternal => {
const weaponInfo = (ExportWeapons as PublicExportPlus.IGenericExport)[weaponName]; const weaponInfo = ExportWeapons[weaponName];
if (!weaponInfo) { if (!weaponInfo) {
throw new Error(`unknown weapon ${weaponName}`); throw new Error(`unknown weapon ${weaponName}`);
@ -137,18 +135,8 @@ export const getItemCategoryByUniqueName = (uniqueName: string) => {
return category; return category;
}; };
namespace PublicExportPlus { export const getSuitByUniqueName = (uniqueName: string): IPowersuit | undefined => {
export interface IGenericExport { return ExportWarframes[uniqueName];
[key: string]: any;
}
export interface IDict {
[key: string]: string | undefined;
}
}
export const getSuitByUniqueName = (uniqueName: string) => {
return (ExportWarframes as PublicExportPlus.IGenericExport)[uniqueName];
}; };
export const getItemByUniqueName = (uniqueName: string) => { export const getItemByUniqueName = (uniqueName: string) => {
@ -162,5 +150,5 @@ export const getItemByName = (name: string) => {
}; };
export const getEnglishString = (key: string): string => { export const getEnglishString = (key: string): string => {
return (dict_en as PublicExportPlus.IDict)[key] ?? key; return dict_en[key] ?? key;
}; };