├── lib ├── migrations │ └── .gitkeep ├── models │ ├── items │ │ ├── model.item.icon.ts │ │ ├── model.item.list.ts │ │ ├── model.item.icon.list.ts │ │ ├── model.item.chat.list.ts │ │ ├── model.item.furniture.list.ts │ │ ├── model.item.resource.list.ts │ │ ├── model.item.chat.ts │ │ ├── model.item.ts │ │ ├── model.item.resource.ts │ │ ├── model.item.furniture.ts │ │ ├── model.item.equip.ts │ │ ├── model.item.ship.ts │ │ └── model.item.drop.ts │ ├── model.gamecfg.base.ts │ ├── shared │ │ ├── model.task.list.ts │ │ ├── model.skill.ts │ │ ├── model.monthly.ts │ │ └── model.task.ts │ ├── social │ │ ├── model.post.list.ts │ │ └── model.post.ts │ ├── meowfficer │ │ ├── model.meowfficer.list.ts │ │ ├── model.mewofficer.skill.list.ts │ │ ├── model.meowfficer.skill.ts │ │ └── model.meowfficer.ts │ ├── model.sharecfg.base.ts │ ├── research │ │ ├── model.research.list.ts │ │ ├── model.research.ts │ │ └── model.research.list.item.ts │ ├── ships │ │ ├── model.ship.construct.list.ts │ │ ├── model.ship.list.ts │ │ ├── model.ship.skin.list.ts │ │ ├── model.ship.skin.list.item.ts │ │ ├── model.ship.retrofit.ts │ │ ├── model.ship.list.item.ts │ │ ├── model.ship.retrofit.node.ts │ │ ├── model.ship.construct.ts │ │ ├── model.ship.blueprint.ts │ │ ├── model.ship.skin.ts │ │ └── model.ship.ts │ ├── equipment │ │ ├── model.equip.list.ts │ │ ├── model.equip.skin.list.ts │ │ ├── model.equip.skin.theme.list.ts │ │ ├── model.equip.skin.theme.ts │ │ ├── model.equip.skin.ts │ │ └── model.equip.ts │ ├── commission │ │ ├── model.commission.list.ts │ │ ├── model.commission.list.item.ts │ │ └── model.commission.ts │ ├── model.sharecfg.list.base.ts │ ├── model.helpers.ts │ ├── gamecfg │ │ └── model..story.ts │ └── model.base.ts ├── requestError.ts ├── resolvers │ ├── resolver.gamecfg.story.ts │ ├── resolver.gamecfg.base.ts │ ├── resolver.base.ts │ └── resolver.sharecfg.base.ts ├── constants.ts ├── schemas.ts ├── github │ ├── github.repository.ts │ └── github.directory.ts ├── createModel.ts ├── handleError.ts ├── validate.ts ├── methods.ts └── database.ts ├── icon.png ├── public ├── nimi.webp ├── favicon.ico ├── nimi-hq.webp └── vercel.svg ├── next-env.d.ts ├── babel.config.json ├── .vscode ├── extensions.json ├── launch.json └── settings.json ├── pages ├── api │ ├── items │ │ ├── index.ts │ │ ├── chat │ │ │ ├── index.ts │ │ │ └── [id].ts │ │ ├── frames │ │ │ ├── index.ts │ │ │ └── [id].ts │ │ ├── resources │ │ │ ├── index.ts │ │ │ └── [id].ts │ │ ├── furniture │ │ │ ├── index.ts │ │ │ └── [id].ts │ │ └── [id].ts │ ├── social │ │ ├── index.ts │ │ └── [id].ts │ ├── tasks │ │ ├── index.ts │ │ └── [id].ts │ ├── equip │ │ ├── index.ts │ │ ├── skins │ │ │ ├── index.ts │ │ │ └── [id].ts │ │ ├── themes │ │ │ ├── index.ts │ │ │ └── [id].ts │ │ └── [id].ts │ ├── research │ │ ├── index.ts │ │ └── [id].ts │ ├── ships │ │ ├── index.ts │ │ ├── construct │ │ │ ├── index.ts │ │ │ └── [id].ts │ │ ├── skins │ │ │ ├── index.ts │ │ │ └── [id].ts │ │ └── [id] │ │ │ ├── retrofit.ts │ │ │ ├── skins.ts │ │ │ ├── blueprint.ts │ │ │ └── index.ts │ ├── commissions │ │ ├── index.ts │ │ └── [id].ts │ ├── meowfficer │ │ ├── index.ts │ │ ├── skill │ │ │ ├── index.ts │ │ │ └── [id].ts │ │ └── [id].ts │ ├── monthly │ │ ├── index.ts │ │ └── [month].ts │ └── story │ │ └── [id].ts ├── _app.tsx └── index.tsx ├── SECURITY.md ├── tests └── index.ts ├── styles ├── globals.css └── Home.module.css ├── next.config.js ├── .gitignore ├── .github ├── FUNDING.yml └── workflows │ └── test.yml ├── tsconfig.json ├── package.json ├── .eslintrc.json ├── README.md └── LICENSE /lib/migrations/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimiiiii/nimi-api/HEAD/icon.png -------------------------------------------------------------------------------- /public/nimi.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimiiiii/nimi-api/HEAD/public/nimi.webp -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimiiiii/nimi-api/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/nimi-hq.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimiiiii/nimi-api/HEAD/public/nimi-hq.webp -------------------------------------------------------------------------------- /next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /babel.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["next/babel"], 3 | "plugins": [ 4 | ["@babel/plugin-proposal-decorators", { "legacy": true }] 5 | ] 6 | } -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "psioniq.psi-header", 4 | "dbaeumer.vscode-eslint", 5 | "esbenp.prettier-vscode" 6 | ] 7 | } -------------------------------------------------------------------------------- /lib/models/items/model.item.icon.ts: -------------------------------------------------------------------------------- 1 | import ChatBubble from "./model.item.chat"; 2 | import { dependsOn } from "../model.helpers"; 3 | 4 | @dependsOn([ "itemIconFrames" ]) 5 | export default class IconFrame extends ChatBubble {} -------------------------------------------------------------------------------- /pages/api/items/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ItemList from "lib/models/items/model.item.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(ItemList); -------------------------------------------------------------------------------- /pages/api/social/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import PostList from "lib/models/social/model.post.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(PostList); -------------------------------------------------------------------------------- /pages/api/tasks/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import TaskList from "lib/models/shared/model.task.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(TaskList); -------------------------------------------------------------------------------- /lib/models/items/model.item.list.ts: -------------------------------------------------------------------------------- 1 | import Item from "./model.item"; 2 | import ShareCfgModelList from "../model.sharecfg.list.base"; 3 | import { dependsOn } from "../model.helpers"; 4 | 5 | @dependsOn([ "items" ]) 6 | export default class ItemList extends ShareCfgModelList { 7 | constructor() { 8 | super(Item); 9 | } 10 | } -------------------------------------------------------------------------------- /pages/api/equip/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import EquipmentList from "lib/models/equipment/model.equip.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(EquipmentList); -------------------------------------------------------------------------------- /pages/api/research/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ResearchList from "lib/models/research/model.research.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(ResearchList); -------------------------------------------------------------------------------- /pages/api/ships/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ShipList from "lib/models/ships/model.ship.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(ShipList); 10 | -------------------------------------------------------------------------------- /pages/_app.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import "../styles/globals.css"; 7 | 8 | function MyApp({ Component, pageProps }) { 9 | return ; 10 | } 11 | 12 | export default MyApp; 13 | -------------------------------------------------------------------------------- /pages/api/items/chat/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ChatBubbleList from "lib/models/items/model.item.chat.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(ChatBubbleList); -------------------------------------------------------------------------------- /pages/api/items/frames/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import IconFrameList from "lib/models/items/model.item.icon.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(IconFrameList); -------------------------------------------------------------------------------- /pages/api/commissions/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import CommissionList from "lib/models/commission/model.commission.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(CommissionList); -------------------------------------------------------------------------------- /pages/api/items/resources/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ResourceList from "lib/models/items/model.item.resource.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(ResourceList); -------------------------------------------------------------------------------- /pages/api/meowfficer/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import MeowfficerList from "lib/models/meowfficer/model.meowfficer.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(MeowfficerList); -------------------------------------------------------------------------------- /pages/api/monthly/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import MonthlySignIn from "lib/models/shared/model.monthly"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(MonthlySignIn); 10 | -------------------------------------------------------------------------------- /pages/api/equip/skins/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import EquipmentSkinList from "lib/models/equipment/model.equip.skin.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(EquipmentSkinList); -------------------------------------------------------------------------------- /pages/api/items/furniture/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import FurnitureList from "lib/models/items/model.item.furniture.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(FurnitureList); -------------------------------------------------------------------------------- /pages/api/ships/construct/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ConstructList from "lib/models/ships/model.ship.construct.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(ConstructList); -------------------------------------------------------------------------------- /pages/api/ships/skins/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ShipSkinList from "lib/models/ships/model.ship.skin.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(ShipSkinList); 10 | -------------------------------------------------------------------------------- /pages/api/equip/themes/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import EquipmentSkinThemeList from "lib/models/equipment/model.equip.skin.theme.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(EquipmentSkinThemeList); -------------------------------------------------------------------------------- /pages/api/meowfficer/skill/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import MeowfficerSkillList from "lib/models/meowfficer/model.mewofficer.skill.list"; 7 | import createModel from "lib/createModel"; 8 | 9 | export default createModel(MeowfficerSkillList); -------------------------------------------------------------------------------- /lib/requestError.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | export default class RequestError extends Error { 7 | code: number; 8 | 9 | constructor(code: number, message: string) { 10 | super(message); 11 | 12 | this.code = code; 13 | } 14 | } -------------------------------------------------------------------------------- /pages/api/items/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetEntryByIdQuery } from "lib/schemas"; 7 | import Item from "lib/models/items/model.item"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(Item, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/tasks/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetEntryByIdQuery } from "lib/schemas"; 7 | import Task from "lib/models/shared/model.task"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(Task, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/social/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetEntryByIdQuery } from "lib/schemas"; 7 | import Post from "lib/models/social/model.post"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(Post, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/story/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetFileByIdQuery } from "lib/schemas"; 7 | import Story from "lib/models/gamecfg/model..story"; 8 | import createModel from "lib/createModel"; 9 | 10 | 11 | export default createModel(Story, GetFileByIdQuery); -------------------------------------------------------------------------------- /pages/api/equip/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Equipment from "lib/models/equipment/model.equip"; 7 | import { GetEntryByIdQuery } from "lib/schemas"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(Equipment, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/ships/[id]/retrofit.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetShipQuery } from "."; 7 | import ShipRetrofit from "lib/models/ships/model.ship.retrofit"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(ShipRetrofit, GetShipQuery); -------------------------------------------------------------------------------- /pages/api/ships/[id]/skins.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetShipQuery } from "."; 7 | import ShipSkinList from "lib/models/ships/model.ship.skin.list"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(ShipSkinList, GetShipQuery); -------------------------------------------------------------------------------- /pages/api/research/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetEntryByIdQuery } from "lib/schemas"; 7 | import Research from "lib/models/research/model.research"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(Research, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/ships/[id]/blueprint.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetShipQuery } from "."; 7 | import ShipBlueprint from "lib/models/ships/model.ship.blueprint"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(ShipBlueprint, GetShipQuery); -------------------------------------------------------------------------------- /pages/api/ships/skins/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetEntryByIdQuery } from "lib/schemas"; 7 | import ShipSkin from "lib/models/ships/model.ship.skin"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(ShipSkin, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/items/chat/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ChatBubble from "lib/models/items/model.item.chat"; 7 | import { GetEntryByIdQuery } from "lib/schemas"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(ChatBubble, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/items/frames/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetEntryByIdQuery } from "lib/schemas"; 7 | import IconFrame from "lib/models/items/model.item.icon"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(IconFrame, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/commissions/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Commission from "lib/models/commission/model.commission"; 7 | import { GetEntryByIdQuery } from "lib/schemas"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(Commission, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/items/furniture/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Furniture from "lib/models/items/model.item.furniture"; 7 | import { GetEntryByIdQuery } from "lib/schemas"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(Furniture, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/items/resources/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetEntryByIdQuery } from "lib/schemas"; 7 | import Resource from "lib/models/items/model.item.resource"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(Resource, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/meowfficer/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetEntryByIdQuery } from "lib/schemas"; 7 | import Meowfficer from "lib/models/meowfficer/model.meowfficer"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(Meowfficer, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/ships/construct/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Construct from "lib/models/ships/model.ship.construct"; 7 | import { GetEntryByIdQuery } from "lib/schemas"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(Construct, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/equip/skins/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import EquipmentSkin from "lib/models/equipment/model.equip.skin"; 7 | import { GetEntryByIdQuery } from "lib/schemas"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(EquipmentSkin, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/equip/themes/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import EquipmentSkinTheme from "lib/models/equipment/model.equip.skin.theme"; 7 | import { GetEntryByIdQuery } from "lib/schemas"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(EquipmentSkinTheme, GetEntryByIdQuery); -------------------------------------------------------------------------------- /pages/api/meowfficer/skill/[id].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetEntryByIdQuery } from "lib/schemas"; 7 | import MeowfficerSkill from "lib/models/meowfficer/model.meowfficer.skill"; 8 | import createModel from "lib/createModel"; 9 | 10 | export default createModel(MeowfficerSkill, GetEntryByIdQuery); -------------------------------------------------------------------------------- /lib/models/model.gamecfg.base.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import GameCfgResolver from "lib/resolvers/resolver.gamecfg.base"; 7 | import Model from "./model.base"; 8 | 9 | export default abstract class GameCfgModel extends Model { 10 | abstract load(resolver: T) : Promise; 11 | } -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | Despite being an API that stores no data from the user, we still take platform security seriously. Here at Nimi, we have a simple but comprehensive way of dealing with security issues. 4 | 5 | ## Reporting a Vulnerability 6 | 7 | Vulnerabilities can be reported directly to [Ayane Satomi](mailto:chinodesuuu@gmail.com) and will be triaged by the team to see if it's a valid security issue. We will publish an advisory as soon as we fixed the bug. 8 | 9 | -------------------------------------------------------------------------------- /tests/index.ts: -------------------------------------------------------------------------------- 1 | import Ship from "lib/models/ships/model.ship"; 2 | import { is } from "uvu/assert"; 3 | import { suite } from "uvu"; 4 | 5 | const $: uvu.Test> = suite("sample test"); 6 | 7 | $("should request some ship info", async () => { 8 | const ship = new Ship(10701, 1); 9 | ship.setResolverDefaults(process.env.GITHUB_TOKEN, process.env.REMOTE_REPO, "en"); 10 | 11 | await ship.run(); 12 | 13 | is((ship as any).name, "Langley"); 14 | }); 15 | 16 | $.run(); -------------------------------------------------------------------------------- /lib/models/shared/model.task.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ShareCfgModelList from "../model.sharecfg.list.base"; 7 | import Task from "./model.task"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "tasks" ]) 11 | export default class TaskList extends ShareCfgModelList { 12 | constructor() { 13 | super(Task); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/social/model.post.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Post from "./model.post"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "social" ]) 11 | export default class PostList extends ShareCfgModelList { 12 | constructor() { 13 | super(Post); 14 | } 15 | } -------------------------------------------------------------------------------- /styles/globals.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | html, 7 | body { 8 | padding: 0; 9 | margin: 0; 10 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, 11 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 12 | } 13 | 14 | a { 15 | color: inherit; 16 | text-decoration: none; 17 | } 18 | 19 | * { 20 | box-sizing: border-box; 21 | } 22 | -------------------------------------------------------------------------------- /lib/models/items/model.item.icon.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import IconFrame from "./model.item.chat"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "itemIconFrames" ]) 11 | export default class IconFrameList extends ShareCfgModelList { 12 | constructor() { 13 | super(IconFrame); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/items/model.item.chat.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ChatBubble from "./model.item.chat"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "itemChatFrames" ]) 11 | export default class ChatBubbleList extends ShareCfgModelList { 12 | constructor() { 13 | super(ChatBubble); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/items/model.item.furniture.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Furniture from "./model.item.furniture"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "furniture" ]) 11 | export default class FurnitureList extends ShareCfgModelList { 12 | constructor() { 13 | super(Furniture); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/items/model.item.resource.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Resource from "./model.item.resource"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "itemPlayerResources" ]) 11 | export default class ResourceList extends ShareCfgModelList { 12 | constructor() { 13 | super(Resource); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/meowfficer/model.meowfficer.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Meowfficer from "./model.meowfficer"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "meowfficers" ]) 11 | export default class MeowfficerList extends ShareCfgModelList { 12 | constructor() { 13 | super(Meowfficer); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/model.sharecfg.base.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Model from "./model.base"; 7 | import ShareCfgResolver from "../resolvers/resolver.sharecfg.base"; 8 | 9 | /** 10 | * A model variant that uses a `ShareCfgResolver` to resolve dependencies 11 | */ 12 | export default abstract class ShareCfgModel extends Model { 13 | constructor() { 14 | super(ShareCfgResolver); 15 | } 16 | } -------------------------------------------------------------------------------- /lib/models/research/model.research.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ResearchItem from "./model.research.list.item"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "research" ]) 11 | export default class ResearchList extends ShareCfgModelList { 12 | constructor() { 13 | super(ResearchItem); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/ships/model.ship.construct.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Construct from "./model.ship.construct"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "shipConstruction" ]) 11 | export default class ConstructList extends ShareCfgModelList { 12 | constructor() { 13 | super(Construct); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/ships/model.ship.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ShareCfgModelList from "../model.sharecfg.list.base"; 7 | import ShipListItem from "./model.ship.list.item"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "shipGroups" ]) 11 | export default class ShipList extends ShareCfgModelList { 12 | constructor() { 13 | super(ShipListItem, "group_type"); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/equipment/model.equip.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import EquipmentItem from "../items/model.item.equip"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "equipStats" ]) 11 | export default class EquipmentItemList extends ShareCfgModelList { 12 | constructor() { 13 | super(EquipmentItem); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/equipment/model.equip.skin.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import EquipmentSkin from "./model.equip.skin"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "equipSkins" ]) 11 | export default class EquipmentSkinList extends ShareCfgModelList { 12 | constructor() { 13 | super(EquipmentSkin); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/commission/model.commission.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import CommissionItem from "./model.commission.list.item"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "commissions" ]) 11 | export default class CommissionList extends ShareCfgModelList { 12 | constructor() { 13 | super(CommissionItem); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/equipment/model.equip.skin.theme.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import EquipSkinTheme from "./model.equip.skin.theme"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "equipSkinThemes" ]) 11 | export default class EquipmentSkinThemeList extends ShareCfgModelList { 12 | constructor() { 13 | super(EquipSkinTheme); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/models/meowfficer/model.mewofficer.skill.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import MeowfficerSkill from "./model.meowfficer.skill"; 7 | import ShareCfgModelList from "../model.sharecfg.list.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "meowfficerSkills" ]) 11 | export default class MeowfficerSkillList extends ShareCfgModelList { 12 | constructor() { 13 | super(MeowfficerSkill); 14 | } 15 | } -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | /* eslint-disable no-undef */ 7 | module.exports = { 8 | async headers() { 9 | return [{ 10 | source: "/:path*", 11 | headers: [ 12 | { 13 | key: "cache-control", 14 | value: "s-maxage=1, stale-while-revalidate" 15 | } 16 | ] 17 | }]; 18 | }, 19 | target: "serverless", 20 | trailingSlash: true 21 | }; 22 | -------------------------------------------------------------------------------- /pages/api/ships/[id]/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import * as joiful from "joiful"; 7 | import Ship from "lib/models/ships/model.ship"; 8 | import createModel from "lib/createModel"; 9 | import { GetEntryByIdQuery, position } from "lib/schemas"; 10 | 11 | export class GetShipQuery extends GetEntryByIdQuery { 12 | @joiful.number().optional().default(1).min(1).max(4) 13 | @position(0) 14 | breakoutLevel?: number 15 | } 16 | 17 | export default createModel(Ship, GetShipQuery); -------------------------------------------------------------------------------- /pages/api/monthly/[month].ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import * as joiful from "joiful"; 7 | import MonthlySignIn from "lib/models/shared/model.monthly"; 8 | import createModel from "lib/createModel"; 9 | import { GetEntryByRegionQuery, position } from "lib/schemas"; 10 | 11 | class GetMonthQuery extends GetEntryByRegionQuery { 12 | @joiful.number().min(1).max(12).required() 13 | @position(0) 14 | month: number 15 | } 16 | 17 | export default createModel(MonthlySignIn, GetMonthQuery); -------------------------------------------------------------------------------- /lib/resolvers/resolver.gamecfg.story.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import GameCfgResolver from "./resolver.gamecfg.base"; 7 | import Repository from "lib/github/github.repository"; 8 | import { ResolverRegion } from "./resolver.base"; 9 | 10 | /** 11 | * A resolver that resolves from the `/story` directory 12 | */ 13 | export default class StoryGameCfgResolver extends GameCfgResolver { 14 | constructor(lang: ResolverRegion, repo: Repository) { 15 | super("/story", lang, repo); 16 | } 17 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # NPMJS lockfile 28 | package-lock.json 29 | 30 | # local env files 31 | .env.local 32 | .env.development.local 33 | .env.test.local 34 | .env.production.local 35 | 36 | # vercel 37 | .vercel 38 | 39 | # local data 40 | /.data 41 | 42 | # TypeDoc output (subject to change) 43 | /docs -------------------------------------------------------------------------------- /lib/resolvers/resolver.gamecfg.base.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Repository from "lib/github/github.repository"; 7 | import Resolver, { ResolverRegion } from "./resolver.base"; 8 | 9 | /** 10 | * A resolver that reolves from the any folder however when resolving, it returns itself. 11 | */ 12 | export default class GameCfgResolver extends Resolver { 13 | constructor(path: string, lang: ResolverRegion, repo: Repository) { 14 | super(path, lang, repo); 15 | } 16 | 17 | async resolve() { 18 | return [this]; 19 | } 20 | } -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: lenitrous 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "node", 6 | "request": "attach", 7 | "name": "Debugger", 8 | "skipFiles": ["/**"], 9 | "port": 9229, 10 | "presentation": { 11 | "hidden": true, 12 | } 13 | }, 14 | { 15 | "name": "Start Server", 16 | "type": "node", 17 | "request": "launch", 18 | "runtimeExecutable": "npm", 19 | "runtimeArgs": ["run", "dev"] 20 | } 21 | ], 22 | "compounds": [ 23 | { 24 | "name": "Start Server with Debugging", 25 | "configurations": [ "Start Server", "Debugger" ], 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /lib/constants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | export const SHIP_ATTR_TYPE = { 7 | 0: "health", 8 | 1: "cannon", 9 | 2: "torpedo", 10 | 3: "antiAir", 11 | 4: "aviation", 12 | 5: "reload", 13 | 6: "armor", 14 | 7: "hit", 15 | 8: "evasion", 16 | 9: "speed", 17 | 10: "luck", 18 | 11: "antiSub" 19 | }; 20 | 21 | export const TAG_REGEX = /<[^>]*>/g; 22 | 23 | export const NAMECODE_REGEX = /{namecode:(\d+)}/; 24 | 25 | export const SCHEMA_POSITION_KEY = "nimi-schema:position"; 26 | 27 | export const MODEL_EXCLUDE_KEY = "nimi-model:exclude"; 28 | 29 | export const MODEL_DEPENDS_KEY = "nimi-model:depends"; -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "**/.data": true, 4 | "**/dist": true, 5 | "**/node_modules": true 6 | }, 7 | "psi-header.changes-tracking": { 8 | "autoHeader": "autoSave", 9 | "excludeGlob": [ 10 | "**.json", 11 | "**.md", 12 | "**.txt" 13 | ] 14 | }, 15 | "psi-header.variables": [ 16 | ["projectCreationYear", "2019"] 17 | ], 18 | "psi-header.templates": [ 19 | { 20 | "language": "*", 21 | "template": [ 22 | "Copyright <> - <> Nathan Alo, Ayane Satomi, et al.", 23 | "Licensed under the GNU General Public License v3", 24 | "See LICENSE for details." 25 | ] 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /lib/models/ships/model.ship.skin.list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ShareCfgModelList from "../model.sharecfg.list.base"; 7 | import ShipSkinListItem from "./model.ship.skin.list.item"; 8 | import { dependsOn, exclude } from "../model.helpers"; 9 | 10 | @dependsOn([ "shipSkins" ]) 11 | export default class ShipSkinList extends ShareCfgModelList { 12 | @exclude() 13 | groupId: number; 14 | 15 | constructor(groupId: number = undefined) { 16 | super(ShipSkinListItem); 17 | 18 | this.groupId = groupId; 19 | } 20 | 21 | modify(skins: any[]) { 22 | return this.groupId !== undefined ? skins.filter(s => s.ship_group == this.groupId) : skins; 23 | } 24 | } -------------------------------------------------------------------------------- /lib/models/items/model.item.chat.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import RequestError from "lib/requestError"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "itemChatFrames" ]) 11 | export default class ChatBubble extends ShareCfgModel { 12 | id: number; 13 | name: string; 14 | description: string; 15 | 16 | constructor(id: number) { 17 | super(); 18 | 19 | this.id = id; 20 | } 21 | 22 | async load(frames: any[]) { 23 | const frame = frames.find(f => f.id == this.id); 24 | 25 | if (!frame) 26 | throw new RequestError(404, `Frame (ID: ${this.id}) was not found.`); 27 | 28 | this.name = frame.name; 29 | this.description = frame.desc; 30 | } 31 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "experimentalDecorators": true, 4 | "emitDecoratorMetadata": true, 5 | "target": "es5", 6 | "lib": ["dom", "dom.iterable", "esnext"], 7 | "allowJs": false, 8 | "skipLibCheck": true, 9 | "strict": false, 10 | "forceConsistentCasingInFileNames": true, 11 | "noEmit": true, 12 | "esModuleInterop": true, 13 | "module": "esnext", 14 | "moduleResolution": "node", 15 | "resolveJsonModule": true, 16 | "isolatedModules": true, 17 | "jsx": "preserve", 18 | "baseUrl": ".", 19 | }, 20 | "ts-node": { 21 | "transpileOnly": true, 22 | "compilerOptions": { 23 | "module": "CommonJS" 24 | }, 25 | "include": [ 26 | "tests/**/*" 27 | ] 28 | }, 29 | "exclude": ["node_modules"], 30 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types.d.ts"] 31 | } -------------------------------------------------------------------------------- /lib/models/items/model.item.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import RequestError from "lib/requestError"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "items" ]) 11 | export default class Item extends ShareCfgModel { 12 | id: number; 13 | name: string; 14 | rarity: number; 15 | assetName: string; 16 | 17 | constructor(id: number) { 18 | super(); 19 | 20 | this.id = id; 21 | } 22 | 23 | async load(items: any[]) { 24 | const item = items.find(i => i.id == this.id); 25 | 26 | if (!item) 27 | throw new RequestError(404, `Item (ID: ${this.id}) is not found.`); 28 | 29 | this.name = item.name.trim(); 30 | this.rarity = item.rarity; 31 | this.assetName = item.icon; 32 | } 33 | } -------------------------------------------------------------------------------- /lib/models/items/model.item.resource.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Item from "./model.item"; 7 | import RequestError from "lib/requestError"; 8 | import ShareCfgModel from "../model.sharecfg.base"; 9 | import { dependsOn } from "../model.helpers"; 10 | 11 | @dependsOn([ "itemPlayerResources" ]) 12 | export default class Resource extends ShareCfgModel { 13 | id: number; 14 | name: string; 15 | item: Item; 16 | 17 | constructor(id: number) { 18 | super(); 19 | 20 | this.id = id; 21 | } 22 | 23 | async load(resources: any[]) { 24 | const data = resources.find(r => r.id == this.id); 25 | 26 | if (!data) 27 | throw new RequestError(404, `Resource (ID: ${this.id}) is not found.`); 28 | 29 | this.name = data.name; 30 | this.item = new Item(data.itemId); 31 | } 32 | } -------------------------------------------------------------------------------- /lib/models/equipment/model.equip.skin.theme.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import EquipmentSkin from "./model.equip.skin"; 7 | import RequestError from "lib/requestError"; 8 | import ShareCfgModelList from "../model.sharecfg.list.base"; 9 | import { dependsOn } from "../model.helpers"; 10 | 11 | @dependsOn([ "equipSkinThemes" ]) 12 | export default class EquipmentSkinTheme extends ShareCfgModelList { 13 | id: number; 14 | name: string; 15 | 16 | constructor(id: number) { 17 | super(EquipmentSkin); 18 | 19 | this.id = id; 20 | } 21 | 22 | modify(themes: any[]) { 23 | const theme = themes.find(t => t.id == this.id); 24 | 25 | if (!theme) 26 | throw new RequestError(404, `Equipment Skin Theme (ID: ${this.id}) is not found.`); 27 | 28 | this.name = theme.name; 29 | 30 | return theme; 31 | } 32 | } -------------------------------------------------------------------------------- /lib/models/items/model.item.furniture.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Item from "./model.item"; 7 | import RequestError from "lib/requestError"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "items", "furniture" ]) 11 | export default class Furniture extends Item { 12 | type: number; 13 | description: string; 14 | 15 | constructor(id: number) { 16 | super(id); 17 | } 18 | 19 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment 20 | // @ts-ignore 21 | async load(items: any[], furniture: any[]) { 22 | await super.load(items); 23 | 24 | const data = furniture.find(f => f.id == this.id); 25 | 26 | if (!data) 27 | throw new RequestError(404, `Furniture (ID: ${this.id}) is not found.`); 28 | 29 | this.type = data.type; 30 | this.description = data.describe; 31 | } 32 | } -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | lint: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | 11 | - name: Setup NodeJS 12 | uses: actions/setup-node@main 13 | with: 14 | node-version: '14.x' 15 | 16 | - name: Install dependencies 17 | run: yarn 18 | 19 | - name: Run linting 20 | run: yarn lint 21 | 22 | test: 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v2 26 | 27 | - name: Setup NodeJS 28 | uses: actions/setup-node@main 29 | with: 30 | node-version: '14.x' 31 | 32 | - name: Start MongoDB 33 | uses: supercharge/mongodb-github-action@1.3.0 34 | with: 35 | mongodb-version: '4.2' 36 | 37 | - name: Install dependencies 38 | run: yarn 39 | 40 | - name: Run tests 41 | run: yarn test 42 | env: 43 | REMOTE_REPO: ${{ secrets.REMOTE_REPO }} 44 | -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /lib/models/equipment/model.equip.skin.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Item from "../items/model.item"; 7 | import RequestError from "lib/requestError"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "equipSkins" ]) 11 | export default class EquipmentSkin extends Item { 12 | themeId: number; 13 | type: number; 14 | description: string; 15 | equipTypes: number[]; 16 | 17 | constructor(id: number) { 18 | super(id); 19 | } 20 | 21 | async load(skins: any[]) { 22 | const skin = skins.find(s => s.id == this.id); 23 | 24 | if (!skin) 25 | throw new RequestError(404, `Equipment Skin (ID: ${this.id}) is not found.`); 26 | 27 | this.name = skin.name?.trim(); 28 | this.rarity = skin.rarity; 29 | this.assetName = skin.icon; 30 | this.themeId = skin.themeId; 31 | this.type = skin.type; 32 | this.description = skin.desc; 33 | this.equipTypes = skin.equip_type; 34 | } 35 | } -------------------------------------------------------------------------------- /lib/models/shared/model.skill.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import RequestError from "lib/requestError"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "skills" ]) 11 | export default class Skill extends ShareCfgModel { 12 | id: number; 13 | name: string; 14 | type: number; 15 | description: string; 16 | descriptionValues: string[]; 17 | 18 | constructor(id: number) { 19 | super(); 20 | this.id = id; 21 | } 22 | 23 | async load(skills: any[]): Promise { 24 | const skill = skills.find(s => s.id == this.id); 25 | 26 | if (!skill) 27 | throw new RequestError(404, `Skill (ID: ${this.id}) is not found.`); 28 | 29 | this.name = skill.name.trim(); 30 | this.type = skill.type; 31 | this.description = skill.desc; 32 | this.descriptionValues = (skill.desc_add[0]) 33 | ? skill.desc_add[0].map(e => e[0]) 34 | : []; 35 | } 36 | } -------------------------------------------------------------------------------- /lib/models/ships/model.ship.skin.list.item.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import RequestError from "lib/requestError"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import { dependsOn, exclude } from "../model.helpers"; 9 | 10 | @dependsOn([ "shipSkins" ]) 11 | export default class ShipSkinListItem extends ShareCfgModel { 12 | @exclude() 13 | data: any; 14 | 15 | id: number; 16 | name: string; 17 | type: number; 18 | description: string; 19 | assetName: string; 20 | 21 | constructor(id: number) { 22 | super(); 23 | 24 | this.id = id; 25 | } 26 | 27 | async load(skins: any[]) { 28 | this.data = skins.find(s => s.id == this.id); 29 | 30 | if (!this.data) 31 | throw new RequestError(404, `Ship Skin (ID: ${this.id}) is not found.`); 32 | 33 | this.name = this.data.name?.trim(); 34 | this.type = this.data.skin_type; 35 | this.description = this.data.desc; 36 | this.assetName = this.data.painting; 37 | } 38 | } -------------------------------------------------------------------------------- /lib/models/meowfficer/model.meowfficer.skill.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import RequestError from "lib/requestError"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | @dependsOn([ "meowfficerSkills" ]) 11 | export default class MeowfficerSkill extends ShareCfgModel { 12 | id: number; 13 | nextId: number; 14 | name: string; 15 | level: number; 16 | description: { [key: number]: string } 17 | assetName: string; 18 | 19 | constructor(id: number) { 20 | super(); 21 | 22 | this.id = id; 23 | } 24 | 25 | async load(skills: any[]) { 26 | const data = skills.find(s => s.id == this.id); 27 | 28 | if (!data) 29 | throw new RequestError(404, `Meowfficer Skill (ID: ${this.id}) is not found.`); 30 | 31 | this.name = data.name; 32 | this.nextId = data.next_id; 33 | this.level = data.lv; 34 | this.assetName = data.icon; 35 | this.description = data.desc; 36 | } 37 | } -------------------------------------------------------------------------------- /lib/models/model.sharecfg.list.base.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ShareCfgModel from "./model.sharecfg.base"; 7 | import { exclude } from "./model.helpers"; 8 | 9 | /** 10 | * A Model that has an entries key and lists all results from it. 11 | */ 12 | export default abstract class ShareCfgModelList extends ShareCfgModel { 13 | @exclude() 14 | ctor: { new(id: number): T }; 15 | 16 | @exclude() 17 | key: string; 18 | 19 | entries : Array = new Array(); 20 | 21 | constructor(ctor: ({ new(id: number): T }), key = "id") { 22 | super(); 23 | 24 | this.key = key; 25 | this.ctor = ctor; 26 | } 27 | 28 | async load(...args: any[]) { 29 | this.entries = this.modify(...args).map((i: { [key: string]: number }) => new this.ctor(i[this.key])); 30 | } 31 | 32 | /** 33 | * Called before the returned entries are mapped into an array. 34 | * @param args Resolved dependencies 35 | */ 36 | modify(...args: any[]) : any[] { return args[0]; } 37 | } -------------------------------------------------------------------------------- /lib/models/model.helpers.ts: -------------------------------------------------------------------------------- 1 | import ShareCfgModel from "./model.sharecfg.base"; 2 | import { MODEL_DEPENDS_KEY, MODEL_EXCLUDE_KEY } from "lib/constants"; 3 | 4 | /** 5 | * Marks a property as private to be excluded from serialization. 6 | */ 7 | export function exclude() : PropertyDecorator { 8 | return function (target: Object, propertyKey: string) { 9 | if (typeof target === "function") 10 | throw new TypeError(`${propertyKey} of type ${typeof target} should not be a function`); 11 | 12 | Reflect.defineMetadata(MODEL_EXCLUDE_KEY, true, target, propertyKey); 13 | }; 14 | } 15 | 16 | /** 17 | * Denote a `ShareCfgModel` depends on data that will be resolved and passed to it's `load` method. 18 | * @param dependencies An array of dependency names as listed in `ShareCfgResolver` 19 | */ 20 | export function dependsOn(dependencies: Array) : ClassDecorator { 21 | return function(target: Function) { 22 | if (!(target.prototype instanceof ShareCfgModel)) 23 | throw new Error("Dependencies may only be applied on of type ShareCfgModels"); 24 | 25 | Reflect.defineMetadata(MODEL_DEPENDS_KEY, dependencies, target); 26 | }; 27 | } -------------------------------------------------------------------------------- /lib/models/items/model.item.equip.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import RequestError from "lib/requestError"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import { dependsOn, exclude } from "../model.helpers"; 9 | 10 | @dependsOn([ "equipStats" ]) 11 | export default class EquipmentItem extends ShareCfgModel { 12 | @exclude() 13 | data: any; 14 | 15 | id: number; 16 | name: string; 17 | type: number; 18 | nation: number; 19 | description: string; 20 | assetName: string; 21 | 22 | constructor(id: number) { 23 | super(); 24 | 25 | this.id = id; 26 | } 27 | 28 | async load(stats: any[]) { 29 | this.data = stats.find(e => e.id == this.id); 30 | 31 | if (!this.data) 32 | throw new RequestError(404, `Equipment (ID: ${this.id}) is not found.`); 33 | 34 | this.name = this.data.name?.trim(); 35 | this.type = this.data.type; 36 | this.nation = this.data.nationality; 37 | this.description = this.data.descrip; 38 | this.assetName = this.data.icon; 39 | } 40 | } -------------------------------------------------------------------------------- /lib/models/commission/model.commission.list.item.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import RequestError from "lib/requestError"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import { dependsOn, exclude } from "../model.helpers"; 9 | 10 | @dependsOn([ "commissions" ]) 11 | export default class CommissionItem extends ShareCfgModel { 12 | @exclude() 13 | data: any; 14 | 15 | id: number; 16 | name: string; 17 | time: number; 18 | description: string; 19 | assetName: string; 20 | 21 | constructor(id: number) { 22 | super(); 23 | 24 | this.id = id; 25 | } 26 | 27 | async load(commissions: any[]) { 28 | const commission = commissions.find(c => c.id == this.id); 29 | 30 | if (!commission) 31 | throw new RequestError(404, `Commission (ID: ${this.id}) is not found.`); 32 | 33 | this.data = commission; 34 | 35 | this.name = commission.title; 36 | this.time = commission.collect_time; 37 | this.description = commission.description; 38 | this.assetName = commission.icon; 39 | } 40 | } -------------------------------------------------------------------------------- /lib/models/ships/model.ship.retrofit.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import RequestError from "lib/requestError"; 7 | import RetrofitNode from "./model.ship.retrofit.node"; 8 | import ShareCfgModel from "lib/models/model.sharecfg.base"; 9 | import { dependsOn, exclude } from "../model.helpers"; 10 | 11 | @dependsOn([ "shipRetrofits" ]) 12 | export default class ShipRetrofit extends ShareCfgModel { 13 | @exclude() 14 | groupId: number; 15 | 16 | nodes: { 17 | row: number, 18 | task: RetrofitNode 19 | }[][]; 20 | 21 | constructor(groupId: number) { 22 | super(); 23 | 24 | this.groupId = groupId; 25 | } 26 | 27 | async load(retrofits: any[]) { 28 | const retrofit = retrofits.find(r => r.group_id == this.groupId); 29 | 30 | if (!retrofit) 31 | throw new RequestError(404, "Ship does not have retrofit data."); 32 | 33 | this.nodes = retrofit.transform_list.map(col => 34 | col.map(([row, id]) => ({ 35 | row, 36 | task: new RetrofitNode(id) 37 | })) 38 | ); 39 | } 40 | } -------------------------------------------------------------------------------- /lib/models/research/model.research.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import DropItem from "../items/model.item.drop"; 7 | import ResearchItem from "./model.research.list.item"; 8 | import ShareCfgModel from "../model.sharecfg.base"; 9 | import { exclude } from "../model.helpers"; 10 | 11 | export default class Research extends ShareCfgModel { 12 | @exclude() 13 | base: any; 14 | 15 | playerLevel: number; 16 | consume: { count: number, item: DropItem }[]; 17 | drops: { count: number, item: DropItem }[]; 18 | 19 | constructor(id: number) { 20 | super(); 21 | 22 | this.base = new ResearchItem(id); 23 | } 24 | 25 | async load() { 26 | const { data } = this.base; 27 | 28 | this.mixin(this.base); 29 | 30 | this.playerLevel = data.lv_limit; 31 | this.consume = data.consume.map(([type, id, count]) => ( 32 | { 33 | count, 34 | item: new DropItem(id, type) 35 | } 36 | )); 37 | this.drops = data.drop_client.map(([type, id, count]) => ( 38 | { 39 | count, 40 | item: new DropItem(id, type) 41 | } 42 | )); 43 | } 44 | } -------------------------------------------------------------------------------- /lib/models/gamecfg/model..story.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import GameCfgModel from "../model.gamecfg.base"; 7 | import StoryGameCfgResolver from "../../resolvers/resolver.gamecfg.story"; 8 | import { exclude } from "../model.helpers"; 9 | 10 | interface Dialogue { 11 | actorId: number, 12 | actorName: string, 13 | text: string, 14 | effects: { 15 | sound: string, 16 | background: string, 17 | backgroundMusic: string 18 | } 19 | } 20 | 21 | export default class Story extends GameCfgModel { 22 | @exclude() 23 | id: string; 24 | 25 | dialogue: Dialogue[] 26 | 27 | constructor(id: string) { 28 | super(StoryGameCfgResolver); 29 | 30 | this.id = id; 31 | } 32 | 33 | async load(resolver: StoryGameCfgResolver) { 34 | const data = await resolver.getFile(this.id + ".json"); 35 | 36 | this.dialogue = data.scripts.map(s => ({ 37 | actorId: s.actor, 38 | actorName: s.actorName, 39 | text: s.say, 40 | effects: { 41 | sound: s.soundeffect, 42 | background: s.bgName, 43 | backgroundMusic: s.bgm 44 | } 45 | })); 46 | } 47 | } -------------------------------------------------------------------------------- /lib/models/research/model.research.list.item.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import RequestError from "lib/requestError"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import { dependsOn, exclude } from "../model.helpers"; 9 | 10 | @dependsOn([ "research" ]) 11 | export default class ResearchItem extends ShareCfgModel { 12 | @exclude() 13 | data: any; 14 | 15 | id: number; 16 | type: number; 17 | rarity: number; 18 | name: string; 19 | title: string; 20 | description: string; 21 | time: number; 22 | blueprintVersion: number; 23 | 24 | constructor(id: number) { 25 | super(); 26 | 27 | this.id = id; 28 | } 29 | 30 | async load(researchs: any[]) { 31 | const research = researchs.find(r => r.id == this.id); 32 | 33 | if (!researchs) 34 | throw new RequestError(404, `Research (ID: ${this.id}) was not found.`); 35 | 36 | this.data = research; 37 | 38 | this.type = research.type; 39 | this.rarity = research.rarity; 40 | this.name = research.name; 41 | this.title = research.sub_name; 42 | this.description = research.desc; 43 | this.time = research.time; 44 | this.blueprintVersion = research.blueprint_version; 45 | } 46 | } -------------------------------------------------------------------------------- /lib/models/ships/model.ship.list.item.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ShareCfgModel from "../model.sharecfg.base"; 7 | import ShipItem from "../items/model.item.ship"; 8 | import { dependsOn, exclude } from "../model.helpers"; 9 | 10 | @dependsOn([ "shipRetrofits", "shipBlueprints" ]) 11 | export default class ShipListItem extends ShareCfgModel { 12 | @exclude() 13 | item: ShipItem; 14 | 15 | id: number; 16 | name: string; 17 | code: number; 18 | type: number; 19 | rarity: number; 20 | nation: string; 21 | groupId: number; 22 | assetName: string; 23 | research: boolean; 24 | retrofit: boolean; 25 | 26 | constructor(groupId: number, breakoutLevel = 1) { 27 | super(); 28 | 29 | this.item = new ShipItem(groupId, breakoutLevel); 30 | } 31 | 32 | async load(retrofits : any[], blueprints : any[]) { 33 | this.mixin(this.item); 34 | 35 | const { stats, group } = this.item; 36 | 37 | this.code = group.code; 38 | this.type = stats.type; 39 | this.groupId = group.group_type; 40 | this.nation = stats.nationality; 41 | this.research = blueprints.some(b => b.id == group.group_type); 42 | this.retrofit = retrofits.some(r => r.group_id == group.group_type); 43 | } 44 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "azur-lane-api-new", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "cross-env NODE_ENV=development NODE_OPTIONS='--inspect' next dev", 7 | "doc": "typedoc --mode file --exclude ./lib/model/**/* --out docs lib", 8 | "lint": "eslint --fix -c .eslintrc.json .", 9 | "build": "next build", 10 | "start": "next start", 11 | "test": "cross-env NODE_PATH='.' uvu -r ts-node/register tests" 12 | }, 13 | "dependencies": { 14 | "@hapi/joi": "^17.1.1", 15 | "@octokit/rest": "^18.0.6", 16 | "cors": "^2.8.5", 17 | "express-rate-limit": "^5.1.3", 18 | "joiful": "^2.0.1", 19 | "mongoose": "^5.10.7", 20 | "next": "9.5.4", 21 | "react": "16.13.1", 22 | "react-dom": "16.13.1", 23 | "reflect-metadata": "^0.1.13", 24 | "snappy": "^6.3.4" 25 | }, 26 | "devDependencies": { 27 | "@babel/core": "^7.11.6", 28 | "@babel/plugin-proposal-decorators": "^7.10.5", 29 | "@octokit/types": "^5.5.0", 30 | "@types/cors": "^2.8.7", 31 | "@types/express-rate-limit": "^5.1.0", 32 | "@types/hapi__joi": "^17.1.5", 33 | "@types/mongoose": "^5.7.36", 34 | "@types/react": "^16.9.49", 35 | "@types/snappy": "^6.0.0", 36 | "@typescript-eslint/eslint-plugin": "^4.2.0", 37 | "@typescript-eslint/parser": "^4.2.0", 38 | "cross-env": "^7.0.2", 39 | "eslint": "^7.9.0", 40 | "ts-node": "^9.0.0", 41 | "typescript": "^4.0.3", 42 | "typedoc": "^0.19.2", 43 | "uvu": "^0.3.3" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/schemas.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import * as joiful from "joiful"; 7 | import { SCHEMA_POSITION_KEY } from "./constants"; 8 | 9 | /** 10 | * The valid schema for language strings. Note it only check `?region=` querystring. 11 | * Use this schema when interacting with models. 12 | */ 13 | export class GetEntryByRegionQuery { 14 | @joiful.string().valid("en", "jp", "tw", "cn", "kr").optional().default("en") 15 | @position(Number.MAX_VALUE) 16 | region?: string; 17 | } 18 | 19 | /** 20 | * The valid schema for models that require to be searched by its numeric id. 21 | */ 22 | export class GetEntryByIdQuery extends GetEntryByRegionQuery { 23 | @joiful.number().required() 24 | @position(Number.MIN_VALUE) 25 | id!: number; 26 | } 27 | 28 | /** 29 | * The valid schema for models that require to be searched by its file name. 30 | */ 31 | export class GetFileByIdQuery extends GetEntryByRegionQuery { 32 | @joiful.string().required() 33 | @position(Number.MIN_VALUE) 34 | id!: string; 35 | } 36 | 37 | /** 38 | * Define what position this property wille be ordered in the schema. 39 | * @param order The position of the property in the schema. 40 | */ 41 | export function position(order: number) { 42 | return function(target: any, propertyKey: string) { 43 | Reflect.defineMetadata(SCHEMA_POSITION_KEY, order, target, propertyKey); 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /lib/models/equipment/model.equip.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import EquipmentItem from "../items/model.item.equip"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import Skill from "../shared/model.skill"; 9 | import { exclude } from "../model.helpers"; 10 | 11 | export default class Equipment extends ShareCfgModel { 12 | @exclude() 13 | item: EquipmentItem; 14 | 15 | specialty: string; 16 | ammoType: string; 17 | torpedoCount: number; 18 | range: number; 19 | angle: number; 20 | scatter: number; 21 | skills: Skill[]; 22 | attributes: { [key: string]: number } 23 | 24 | constructor(id: number) { 25 | super(); 26 | 27 | this.item = new EquipmentItem(id); 28 | } 29 | 30 | async load() { 31 | const { data } = this.item; 32 | 33 | this.specialty = data.specialty; 34 | this.ammoType = data.ammo; 35 | this.torpedoCount = data.torpedo_ammo; 36 | this.range = data.range; 37 | this.angle = data.angle; 38 | this.scatter = data.scatter; 39 | 40 | this.skills = data.skill_id.map(id => new Skill(id)); 41 | this.attributes = Object.keys(data) 42 | .filter(k => /attribute_(\d+)/.test(k)) 43 | .reduce((obj, key, index) => { 44 | obj[key] = data[`value_${index + 1}`]; 45 | return obj; 46 | }, {}); 47 | } 48 | } -------------------------------------------------------------------------------- /lib/github/github.repository.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Directory from "./github.directory"; 7 | import { Octokit } from "@octokit/rest"; 8 | 9 | /** 10 | * Represents a Repository on GitHub to pull data from 11 | */ 12 | export default class Repository { 13 | token: string; 14 | repoString: string; 15 | owner: string; 16 | name: string; 17 | branch: string; 18 | github: Octokit; 19 | 20 | /** 21 | * 22 | * @param token Your GitHub Application Token 23 | * @param repoString the string used for the repository formatted as owner/name 24 | * @param branch the branch to pull data from 25 | */ 26 | constructor (token: string, owner: string, name: string, branch = "master") { 27 | this.owner = owner; 28 | this.name = name; 29 | this.branch = branch; 30 | this.github = new Octokit({ auth: token }); 31 | } 32 | 33 | /** 34 | * Gets the directory tree for the specific git repository in GitHub 35 | * @param path the path of where the data is 36 | */ 37 | async getDirectory(path: string) : Promise { 38 | const { data: { tree } } = (await this.github.git.getTree({ 39 | repo: this.name, 40 | owner: this.owner, 41 | tree_sha: `${this.branch}:${path}` 42 | })); 43 | 44 | return new Directory(this.github, this, path, tree); 45 | } 46 | } -------------------------------------------------------------------------------- /lib/models/meowfficer/model.meowfficer.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import MeowfficerSkill from "./model.meowfficer.skill"; 7 | import RequestError from "lib/requestError"; 8 | import ShareCfgModel from "../model.sharecfg.base"; 9 | import { dependsOn } from "../model.helpers"; 10 | 11 | @dependsOn([ "meowfficers" ]) 12 | export default class Meowfficer extends ShareCfgModel { 13 | id: number; 14 | groupId: number; 15 | name: string; 16 | rarity: number; 17 | nation: number; 18 | assetName: string; 19 | background: string; 20 | skill: MeowfficerSkill; 21 | command: number; 22 | support: number; 23 | tactic: number; 24 | 25 | constructor(id: number) { 26 | super(); 27 | 28 | this.id = id; 29 | } 30 | 31 | async load(meowfficers: any[]) { 32 | const data = meowfficers.find(m => m.id == this.id); 33 | 34 | if (!data) 35 | throw new RequestError(404, `Meowfficer (ID: ${this.id}) is not found.`); 36 | 37 | this.groupId = data.group_type; 38 | this.name = data.name?.trim(); 39 | this.rarity = data.rarity; 40 | this.nation = data.nationality; 41 | this.assetName = data.painting; 42 | this.background = data.bg; 43 | this.command = data.command_value; 44 | this.support = data.support_value; 45 | this.tactic = data.tactic_value; 46 | this.skill = new MeowfficerSkill(data.skill_id); 47 | } 48 | } -------------------------------------------------------------------------------- /lib/models/shared/model.monthly.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import DropItem from "../items/model.item.drop"; 7 | import RequestError from "lib/requestError"; 8 | import ShareCfgModel from "../model.sharecfg.base"; 9 | import { dependsOn } from "../model.helpers"; 10 | 11 | type MonthData = { [key: number]: { count: number, Item: DropItem } }; 12 | 13 | @dependsOn([ "monthlySignIn" ]) 14 | export default class MonthlySignIn extends ShareCfgModel { 15 | entries: MonthData[]; 16 | month: number; 17 | days: MonthData 18 | 19 | constructor(month: number = undefined) { 20 | super(); 21 | 22 | if (month !== undefined && month < 12 && month > 1) 23 | throw new RequestError(400, "Month must be within 1 - 12"); 24 | 25 | this.month = month; 26 | } 27 | 28 | async load(monthly: any[]) { 29 | if (this.month) { 30 | const month = monthly.find(m => m.id == this.month); 31 | this.days = formatMonth(month); 32 | } else { 33 | this.entries = monthly.map(m => formatMonth(m)); 34 | } 35 | } 36 | } 37 | 38 | function formatMonth(month) { 39 | return Object.keys(month) 40 | .filter(k => /day(\d+)/.test(k)) 41 | .reduce((obj, val, index) => { 42 | const [[type, id, count]] = month[val]; 43 | obj[index] = { 44 | count, 45 | item: new DropItem(id, type) 46 | }; 47 | return obj; 48 | }, {}); 49 | } -------------------------------------------------------------------------------- /lib/models/shared/model.task.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import DropItem from "../items/model.item.drop"; 7 | import RequestError from "lib/requestError"; 8 | import ShareCfgModel from "../model.sharecfg.base"; 9 | import { dependsOn } from "../model.helpers"; 10 | 11 | @dependsOn([ "tasks" ]) 12 | export default class Task extends ShareCfgModel { 13 | id: number; 14 | type: number; 15 | subType: number; 16 | name: string; 17 | description: string; 18 | minLevel: number; 19 | nextTaskId: number; 20 | storyId: number; 21 | rewards: { count: number, item: DropItem }[] 22 | 23 | constructor(id: number) { 24 | super(); 25 | 26 | this.id = id; 27 | } 28 | 29 | async load(tasks: any[]) { 30 | const task = tasks.find(t => t.id == this.id); 31 | 32 | if (!task) 33 | throw new RequestError(404, `Task (ID: ${this.id}) is not found.`); 34 | 35 | this.type = task.type; 36 | this.subType = task.sub_type; 37 | this.name = task.name; 38 | this.description = task.desc; 39 | this.minLevel = task.level; 40 | this.nextTaskId = task.next_task; 41 | this.storyId = task.storyId; 42 | 43 | // TODO: Parse Lua Strings (for some reason they are) 44 | this.rewards = Array.isArray(task.award_display) 45 | ? task.award_display.map(([type, id, count]) => 46 | ({ 47 | count, 48 | item: new DropItem(id, type) 49 | }) 50 | ) 51 | : []; 52 | } 53 | } -------------------------------------------------------------------------------- /lib/models/items/model.item.ship.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import RequestError from "lib/requestError"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import { dependsOn, exclude } from "../model.helpers"; 9 | 10 | @dependsOn([ "ships", "shipGroups", "shipStats", "shipSkins" ]) 11 | export default class ShipItem extends ShareCfgModel { 12 | @exclude() 13 | ship: any; 14 | 15 | @exclude() 16 | stats: any; 17 | 18 | @exclude() 19 | skin: any; 20 | 21 | @exclude() 22 | group: any; 23 | 24 | id: number; 25 | groupId: number; 26 | name: string; 27 | rarity: number; 28 | assetName: string; 29 | breakoutLevel: number; 30 | 31 | constructor(groupId: number, breakoutLevel = 1) { 32 | super(); 33 | 34 | if (breakoutLevel > 4 || breakoutLevel < 1) 35 | throw new RequestError(400, "Breakout level should only be between 1 and 4."); 36 | 37 | this.groupId = groupId; 38 | this.breakoutLevel = breakoutLevel; 39 | } 40 | 41 | async load(ships: any[], groups: any[], stats: any[], skins: any[]) { 42 | this.group = groups.find(g => g.group_type == this.groupId); 43 | 44 | if (!this.group) 45 | throw new RequestError(404, `Ship Group (ID: ${this.groupId}) not found.`); 46 | 47 | this.ship = ships.find(s => s.group_type == this.group.group_type); 48 | this.stats = stats.find(s => s.id == this.ship.id); 49 | this.skin = skins.find(s => s.id == this.stats.skin_id); 50 | 51 | this.id = this.ship.id; 52 | this.name = this.stats.name?.trim(); 53 | this.rarity = this.stats.rarity; 54 | this.assetName = this.skin.painting; 55 | } 56 | } -------------------------------------------------------------------------------- /lib/models/ships/model.ship.retrofit.node.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Item from "../items/model.item"; 7 | import RequestError from "lib/requestError"; 8 | import ShareCfgModel from "../model.sharecfg.base"; 9 | import Skill from "../shared/model.skill"; 10 | import { dependsOn } from "../model.helpers"; 11 | 12 | @dependsOn([ "shipRetrofitTasks" ]) 13 | export default class RetrofitNode extends ShareCfgModel { 14 | id: number; 15 | name: string; 16 | minLevel: number; 17 | minStars: number; 18 | assetName: string; 19 | prerequisite: number; 20 | skill: Skill; 21 | cost: { 22 | gold: number, 23 | ship: number, 24 | item: { 25 | count: number, 26 | data: Item 27 | }[] 28 | } 29 | 30 | constructor(id: number) { 31 | super(); 32 | 33 | this.id = id; 34 | } 35 | 36 | async load(tasks: any[]) { 37 | const data = tasks.find(t => t.id == this.id); 38 | 39 | if (!data) 40 | throw new RequestError(404, `Retrofit Task (ID ${this.id}) is not found.`); 41 | 42 | this.name = data.name; 43 | this.minLevel = data.level_limit; 44 | this.minStars = data.star_limit; 45 | this.assetName = data.icon; 46 | this.prerequisite = data.condition_id; 47 | this.skill = (data.skill_id) ? new Skill(data.skill_id) : null; 48 | this.cost = { 49 | gold: data.use_gold, 50 | ship: data.use_ship, 51 | item: data.use_item.map(e => 52 | e.map(([id, count]) => ({ 53 | count, 54 | data: new Item(id) 55 | })) 56 | ) 57 | }; 58 | } 59 | } -------------------------------------------------------------------------------- /lib/models/ships/model.ship.construct.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Item from "../items/model.item"; 7 | import RequestError from "lib/requestError"; 8 | import ShareCfgModel from "../model.sharecfg.base"; 9 | import { dependsOn } from "../model.helpers"; 10 | import { NAMECODE_REGEX, TAG_REGEX } from "lib/constants"; 11 | 12 | @dependsOn([ "shipConstruction", "codes" ]) 13 | export default class Construct extends ShareCfgModel { 14 | id: number; 15 | type: number; 16 | name: string; 17 | cost: { currency: number, gold: number }; 18 | rate: { name: string, percentage: number, pickup?: boolean } 19 | currency: Item; 20 | 21 | constructor(id: number) { 22 | super(); 23 | 24 | this.id = id; 25 | } 26 | 27 | async load(constructs: any[], codes: any[]) { 28 | const construct = constructs.find(c => c.id == this.id); 29 | 30 | if (!construct) 31 | throw new RequestError(404, `Construct (ID: ${this.id}) was not found.`); 32 | 33 | this.type = construct.type; 34 | this.name = construct.name; 35 | this.cost = { currency: construct.number_1, gold: construct.use_gold }; 36 | this.rate = construct.rate_tip.map((t: string) => { 37 | const [ key, value ] = t.replace(TAG_REGEX, "").replace("(up!)", "").split(":"); 38 | const name = (NAMECODE_REGEX.test(key)) 39 | ? codes.find(n => n.id == parseInt(NAMECODE_REGEX.exec(key).pop()))?.name?.trim() 40 | : key; 41 | const percentage = parseFloat(value); 42 | const pickup = t.includes("up!"); 43 | return { name, percentage, pickup }; 44 | }); 45 | this.currency = new Item(construct.use_item); 46 | } 47 | } -------------------------------------------------------------------------------- /lib/models/ships/model.ship.blueprint.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Item from "../items/model.item"; 7 | import RequestError from "lib/requestError"; 8 | import ShareCfgModel from "../model.sharecfg.base"; 9 | import Skill from "../shared/model.skill"; 10 | import Task from "../shared/model.task"; 11 | import { dependsOn, exclude } from "../model.helpers"; 12 | 13 | @dependsOn([ "shipBlueprints" ]) 14 | export default class ShipBlueprint extends ShareCfgModel { 15 | @exclude() 16 | groupId: number; 17 | 18 | name: string; 19 | description: string; 20 | dungeonId: number; 21 | blueprint: Item; 22 | skills: { from: Skill, to: Skill }[]; 23 | prerequisite: Task; 24 | tasks: { delay: number, task: Task } 25 | 26 | constructor(groupId: number) { 27 | super(); 28 | 29 | this.groupId = groupId; 30 | } 31 | 32 | async load(blueprints: any[]) { 33 | const blueprint = blueprints.find(b => b.id == this.groupId); 34 | 35 | if (!blueprint) 36 | throw new RequestError(404, `Ship Group (ID: ${this.groupId}) does not have blueprint data.`); 37 | 38 | this.name = blueprint.name; 39 | this.description = blueprint.unlock_word; 40 | this.dungeonId = blueprint.simulate_dungeon; 41 | 42 | this.blueprint = (blueprint.strengthen_item > 0) ? new Item(blueprint.strengthen_item) : undefined; 43 | 44 | this.skills = blueprint.change_skill.map(([from, to]) => 45 | ({ from: new Skill(from), to: new Skill(to) }) 46 | ); 47 | 48 | this.prerequisite = new Task(blueprint.unlock_task_open_condition); 49 | this.tasks = blueprint.unlock_task.map(([id, opensIn]) => 50 | ({ 51 | delay: opensIn, 52 | task: new Task(id) 53 | }) 54 | ); 55 | } 56 | } -------------------------------------------------------------------------------- /lib/createModel.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { GetEntryByRegionQuery } from "./schemas"; 7 | import { IModel } from "./models/model.base"; 8 | import { ResolverRegion } from "./resolvers/resolver.base"; 9 | import { SCHEMA_POSITION_KEY } from "./constants"; 10 | import methods from "./methods"; 11 | import { NextApiHandler, NextApiResponse } from "next"; 12 | import validate, { QueriedNextApiRequest } from "./validate"; 13 | 14 | type Newable = new (...args: any[]) => T; 15 | 16 | function validateAction(schema: Newable, model: Newable) : NextApiHandler { 17 | return async function (req: QueriedNextApiRequest, res: NextApiResponse) { 18 | const order = Object.keys(req.body) 19 | .map(k => [ k, Reflect.getMetadata(SCHEMA_POSITION_KEY, new schema(), k) ?? 0 ]); 20 | const args = order.sort((a, b) => a[1] - b[1]).map(e => req.body[e[0]]); 21 | 22 | // In the default schema structure, "region" has the value Number.MAX_VALUE. 23 | // This means region identifier will always be at the end of the array. 24 | const region : ResolverRegion = args.pop(); 25 | 26 | const instance = new model(...args); 27 | instance.setResolverDefaults(process.env.GITHUB_TOKEN, process.env.REMOTE_REPO, region); 28 | 29 | const serialized = await instance.run(); 30 | res.status(200).json(serialized); 31 | }; 32 | } 33 | 34 | /** 35 | * A factory method that creates a `NextApiHandler` using the provided model and schema. 36 | * @param model The model to be used in serialization. 37 | * @param schema The model's argument as a schema that will be passed during its initialization. 38 | */ 39 | export default function createModel( 40 | model: Newable, 41 | schema: Newable = GetEntryByRegionQuery 42 | ) { 43 | return methods({ get: validate(schema, validateAction(schema, model)) }); 44 | } -------------------------------------------------------------------------------- /lib/models/commission/model.commission.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import CommissionItem from "./model.commission.list.item"; 7 | import DropItem from "../items/model.item.drop"; 8 | import ShareCfgModel from "../model.sharecfg.base"; 9 | import { exclude } from "../model.helpers"; 10 | 11 | export default class Commission extends ShareCfgModel { 12 | @exclude() 13 | base: CommissionItem; 14 | 15 | oil: number; 16 | type: number; 17 | requirements: { 18 | shipCount: number, 19 | shipTypes: number[], 20 | shipLevel: number, 21 | playerLevel: number 22 | }; 23 | drops: { 24 | guaranteed: { count: string, item: DropItem }[], 25 | special: { count: string, item: DropItem }, 26 | gold: number, 27 | oil: number, 28 | exp: number 29 | }; 30 | 31 | constructor(id: number) { 32 | super(); 33 | 34 | this.base = new CommissionItem(id); 35 | } 36 | 37 | async load() { 38 | const { data } = this.base; 39 | 40 | this.mixin(this.base); 41 | 42 | this.oil = data.oil; 43 | this.type = data.type; 44 | this.requirements = { 45 | shipCount: data.ship_num, 46 | shipTypes: data.ship_type, 47 | shipLevel: data.ship_lv, 48 | playerLevel: data.lv 49 | }; 50 | 51 | this.drops = { 52 | guaranteed: data.drop_display.map(d => ( 53 | { 54 | count: d.nums, 55 | item: new DropItem(d.id, d.type) 56 | } 57 | )), 58 | special: (!Array.isArray(data.special_drop)) 59 | ? { item: new DropItem(data.special_drop.id, data.special_drop.type), count: data.special_drop.nums } 60 | : null, 61 | gold: data.drop_gold_max, 62 | oil: data.drop_oil_max, 63 | exp: data.exp 64 | }; 65 | } 66 | } -------------------------------------------------------------------------------- /lib/handleError.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * From: https://github.com/ClarityCafe/Aya 3 | * 4 | * Copyright (c) 2020 Ayane Satomi, Michael Mitchell, et al. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import { NextApiHandler } from "next"; 26 | import RequestError from "lib/requestError"; 27 | 28 | function handleError(fn: NextApiHandler) : NextApiHandler { 29 | return async function (req, res) { 30 | try { 31 | return await fn(req, res); 32 | } catch (error) { 33 | const code = (error instanceof RequestError) ? error.code : 500; 34 | const isServerError = code === 500; 35 | 36 | const message = !isServerError ? error.message : "An internal server error has occured."; 37 | res.status(code).json({ code, message }); 38 | 39 | if (process.env.NODE_ENV === "development" && isServerError) 40 | console.error(error.stack); 41 | } 42 | }; 43 | } 44 | 45 | export default handleError; -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": false, 4 | "es2021": true 5 | }, 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/recommended" 9 | ], 10 | "parser": "@typescript-eslint/parser", 11 | "parserOptions": { 12 | "ecmaVersion": 12, 13 | "sourceType": "module" 14 | }, 15 | "ignorePatterns": ["old/*", "node_modules/**", "docs/*"], 16 | "plugins": [ 17 | "@typescript-eslint" 18 | ], 19 | "rules": { 20 | "sort-imports": [ 21 | "warn", 22 | { 23 | "memberSyntaxSortOrder": [ 24 | "all", 25 | "single", 26 | "multiple", 27 | "none" 28 | ] 29 | } 30 | ], 31 | "semi": [ 32 | "error", 33 | "always" 34 | ], 35 | "no-var": "error", 36 | "indent": [ 37 | "warn", 38 | 4, 39 | { 40 | "SwitchCase": 1 41 | } 42 | ], 43 | "quotes": [ 44 | "warn", 45 | "double", 46 | { 47 | "avoidEscape": true 48 | } 49 | ], 50 | "max-len": [ 51 | "warn", 52 | { 53 | "code": 120 54 | } 55 | ], 56 | "comma-dangle": [ 57 | "error", 58 | "never" 59 | ], 60 | "no-trailing-spaces": [ 61 | "warn", 62 | { 63 | "ignoreComments": true 64 | } 65 | ], 66 | "object-curly-spacing": [ 67 | "warn", 68 | "always" 69 | ], 70 | "no-empty-function": "off", 71 | "no-case-declarations": "off", 72 | "@typescript-eslint/ban-types": "off", 73 | "@typescript-eslint/no-explicit-any": "off", 74 | "@typescript-eslint/explicit-module-boundary-types": "off", 75 | "@typescript-eslint/no-empty-function": [ 76 | "off" 77 | ] 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lib/validate.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * From: https://github.com/ClarityCafe/Aya 3 | * Copyright (c) 2020 Ayane Satomi, Michael Mitchell, et al. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | import * as joiful from "joiful"; 25 | import { NextApiHandler, NextApiRequest, NextApiResponse } from "next"; 26 | 27 | export interface QueriedNextApiRequest extends NextApiRequest { 28 | body: T, 29 | } 30 | 31 | export type QueriedNextApiHandler = (req: QueriedNextApiRequest, res: NextApiResponse) => void | Promise; 32 | 33 | export enum ValidationTarget { 34 | Body = "body", 35 | Query = "query" 36 | } 37 | 38 | function validate( 39 | schema: new(...args: any[]) => T, 40 | handle: QueriedNextApiHandler, 41 | target = ValidationTarget.Query 42 | ) : NextApiHandler { 43 | return function (req, res) { 44 | const { error, value } = joiful.validateAsClass(req[target], schema); 45 | req.body = value; 46 | 47 | if (!error) 48 | return handle(req, res); 49 | 50 | res.status(400).json({ code: 400, message: error.message }); 51 | }; 52 | } 53 | 54 | export default validate; -------------------------------------------------------------------------------- /lib/models/items/model.item.drop.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ChatBubble from "./model.item.chat"; 7 | import EquipmentItem from "./model.item.equip"; 8 | import EquipmentSkin from "../equipment/model.equip.skin"; 9 | import Furniture from "./model.item.furniture"; 10 | import IconFrame from "./model.item.icon"; 11 | import Item from "./model.item"; 12 | import Resource from "./model.item.resource"; 13 | import ShareCfgModel from "../model.sharecfg.base"; 14 | import ShipItem from "./model.item.ship"; 15 | import ShipSkinListItem from "../ships/model.ship.skin.list.item"; 16 | 17 | enum DropType { 18 | Resource = 1, 19 | Item, 20 | Equipment, 21 | Ship, 22 | Furniture, 23 | Strategy, 24 | ShipSkin, 25 | VItem, // ??? 26 | EquipmentSkin, 27 | ShipNPC, 28 | WorldItem = 12, 29 | IconFrame = 14, 30 | ChatFrame, 31 | Emoji = 17 32 | } 33 | 34 | export default class DropItem extends ShareCfgModel { 35 | type: DropType; 36 | item: ShareCfgModel; 37 | 38 | constructor(id: number, type: DropType) { 39 | super(); 40 | 41 | this.type = type; 42 | 43 | switch (type) { 44 | case DropType.Resource: 45 | this.item = new Resource(id); 46 | break; 47 | 48 | case DropType.Item: 49 | this.item = new Item(id); 50 | break; 51 | 52 | case DropType.Equipment: 53 | this.item = new EquipmentItem(id); 54 | break; 55 | 56 | case DropType.Ship: 57 | this.item = new ShipItem(id); 58 | break; 59 | 60 | case DropType.Furniture: 61 | this.item = new Furniture(id); 62 | break; 63 | 64 | case DropType.EquipmentSkin: 65 | this.item = new EquipmentSkin(id); 66 | break; 67 | 68 | case DropType.ShipSkin: 69 | this.item = new ShipSkinListItem(id); 70 | break; 71 | 72 | case DropType.ChatFrame: 73 | this.item = new ChatBubble(id); 74 | break; 75 | 76 | case DropType.IconFrame: 77 | this.item = new IconFrame(id); 78 | break; 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /pages/index.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Head from "next/head"; 7 | import styles from "../styles/Home.module.css"; 8 | 9 | export default function Home() { 10 | return ( 11 | 12 | 13 | Nimi 14 | 15 | 16 | 17 | 18 | 19 | 20 | Welcome to Nimi! 21 | 22 | 23 | 24 | Nimi is an unofficial API for Azur Lane based on Next.js. 25 | 26 | 27 | 28 | 29 | Documentation → 30 | Find in-depth information about Nimi's API. 31 | 32 | 33 | Contribute! → 34 | Help us make Nimi better by sharing your ideas in GitHub. 35 | 36 | 37 | Platform Status → 38 | 39 | Check if the API is currently available 40 | (PS: you can change this too if you plan to run your own version). 41 | 42 | 43 | 44 | 45 | 46 | 56 | 57 | ); 58 | } 59 | -------------------------------------------------------------------------------- /lib/models/social/model.post.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import RequestError from "lib/requestError"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import { dependsOn } from "../model.helpers"; 9 | 10 | interface JuustagramPost { 11 | name: string, 12 | icon: string, 13 | post: string, 14 | picture: string, 15 | replies: JuustagramPost[] 16 | } 17 | 18 | @dependsOn([ "social", "socialNpc", "socialNpcGroup", "lang" ]) 19 | export default class Post extends ShareCfgModel implements JuustagramPost { 20 | id: number; 21 | name: string; 22 | icon: string; 23 | post: string; 24 | picture: string; 25 | replies: JuustagramPost[]; 26 | 27 | constructor(id: number) { 28 | super(); 29 | 30 | this.id = id; 31 | } 32 | 33 | async load(posts: any[], npcs: any[], groups: any[], lang: any) { 34 | const post = posts.find(p => p.id == this.id); 35 | 36 | if (!post) 37 | throw new RequestError(404, `Juustagram Post (ID: ${this.id}) is not found.`); 38 | 39 | this.name = post.name; 40 | this.icon = post.sculpture; 41 | this.post = lang[post.message_persist]?.value; 42 | this.picture = post.picture_persist; 43 | 44 | this.replies = (Array.isArray(post.npc_discuss_persist)) 45 | ? post.npc_discuss_persist.map(id => { 46 | const reply = npcs.find(n => n.id == id); 47 | const owner = groups.find(g => g.ship_group == reply.ship_group); 48 | 49 | return { 50 | name: owner.name, 51 | icon: owner.sculpture, 52 | post: lang[reply.message_persist]?.value, 53 | replies: (Array.isArray(reply.npc_reply_persist)) 54 | ? reply.npc_reply_persist.map(id => { 55 | const reply = npcs.find(n => n.id == id); 56 | const owner = groups.find(g => g.ship_group == reply.ship_group); 57 | 58 | return { 59 | name: owner.name, 60 | icon: owner.sculpture, 61 | post: lang[reply.message_persist]?.value 62 | }; 63 | }) 64 | : [] 65 | }; 66 | }) 67 | : []; 68 | } 69 | } -------------------------------------------------------------------------------- /lib/github/github.directory.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { Octokit } from "@octokit/rest"; 7 | import Repository from "./github.repository"; 8 | 9 | type TreeItem = { 10 | path: string; 11 | mode: string; 12 | type: string; 13 | size: number; 14 | sha: string; 15 | url: string; 16 | } 17 | 18 | /** 19 | * Represents a directory in GitHub 20 | */ 21 | export default class Directory { 22 | github: Octokit; 23 | repo: Repository; 24 | path: string; 25 | tree: TreeItem[]; 26 | 27 | /** 28 | * 29 | * @param github The GitHub API 30 | * @param repo The repository that instantiated the directory listing 31 | * @param path The relative path that leads to this directory 32 | * @param tree The directory listing 33 | */ 34 | constructor(github: Octokit, repo: Repository, path: string, tree: TreeItem[]) { 35 | this.github = github; 36 | this.repo = repo; 37 | this.path = path; 38 | this.tree = tree; 39 | } 40 | 41 | /** 42 | * Obtain a file's metadata from a directory 43 | * @param name The file to retrieve 44 | */ 45 | getFile(name: string) : TreeItem { 46 | const file = this.tree.find(f => f.path == name && f.type == "blob"); 47 | return file ? file : null; 48 | } 49 | 50 | /** 51 | * Get a subdirectory from a path. 52 | * @param name The file to retrieve 53 | */ 54 | async getDirectory(name: string) : Promise { 55 | const tree = this.tree.find(f => f.path == name && f.type == "tree"); 56 | 57 | if (!tree) 58 | return null; 59 | 60 | return await this.repo.getDirectory(this.path + "/" + tree.path); 61 | } 62 | 63 | /** 64 | * Download a file from the repository 65 | * @param name The file to download 66 | */ 67 | async download(name: string) : Promise { 68 | const file = this.getFile(name); 69 | 70 | const blob = await this.github.git.getBlob({ 71 | repo: this.repo.name, 72 | owner: this.repo.owner, 73 | file_sha: file.sha 74 | }); 75 | 76 | // This is valid. Typescript just doesn't want it. I hate you. 77 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment 78 | // @ts-ignore 79 | return Buffer.from(blob.data.content, blob.data.encoding).toString("utf-8"); 80 | } 81 | } -------------------------------------------------------------------------------- /lib/methods.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * From: https://github.com/ClarityCafe/Aya 3 | * 4 | * Copyright (c) 2020 Ayane Satomi, Michael Mitchell, et al. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import Cors from "cors"; 26 | import RateLimit from "express-rate-limit"; 27 | import handleError from "./handleError"; 28 | import { NextApiHandler, NextApiRequest, NextApiResponse } from "next"; 29 | 30 | const cors = initMiddleware(Cors()); 31 | const rate = initMiddleware(RateLimit({ windowMs: 60 * 60 * 1000, max: 150 })); 32 | 33 | export type HTTPMethods = 34 | | "get" 35 | | "head" 36 | | "post" 37 | | "put" 38 | | "delete" 39 | | "connect" 40 | | "trace" 41 | | "patch"; 42 | 43 | export default function methods(handlers: { [key in HTTPMethods]?: NextApiHandler }) : NextApiHandler { 44 | return async function (req, res) { 45 | await rate(req, res); 46 | await cors(req, res); 47 | 48 | const handle = handlers[req.method.toLowerCase()]; 49 | 50 | if (typeof handle === "function") 51 | return handleError(handle)(req, res); 52 | 53 | res.status(405).json({ code: 405, message: "Method not available on this endpoint" }); 54 | }; 55 | } 56 | 57 | function initMiddleware(middleware: any) { 58 | return (req: NextApiRequest, res: NextApiResponse) => { 59 | return new Promise((resolve, reject) => { 60 | middleware(req, res, (result) => { 61 | if (result instanceof Error) 62 | return reject(result); 63 | 64 | return resolve(result); 65 | }); 66 | }); 67 | }; 68 | } -------------------------------------------------------------------------------- /styles/Home.module.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | .container { 7 | min-height: 100vh; 8 | padding: 0 0.5rem; 9 | display: flex; 10 | flex-direction: column; 11 | justify-content: center; 12 | align-items: center; 13 | } 14 | 15 | .main { 16 | padding: 5rem 0; 17 | flex: 1; 18 | display: flex; 19 | flex-direction: column; 20 | justify-content: center; 21 | align-items: center; 22 | } 23 | 24 | .footer { 25 | width: 100%; 26 | height: 100px; 27 | border-top: 1px solid #eaeaea; 28 | display: flex; 29 | justify-content: center; 30 | align-items: center; 31 | } 32 | 33 | .footer img { 34 | margin-left: 0.5rem; 35 | } 36 | 37 | .footer a { 38 | display: flex; 39 | justify-content: center; 40 | align-items: center; 41 | } 42 | 43 | .title a { 44 | color: #0070f3; 45 | text-decoration: none; 46 | } 47 | 48 | .title a:hover, 49 | .title a:focus, 50 | .title a:active { 51 | text-decoration: underline; 52 | } 53 | 54 | .description a { 55 | color: #0070f3; 56 | text-decoration: none; 57 | } 58 | 59 | .description a:hover, 60 | .description a:focus, 61 | .description a:active { 62 | text-decoration: underline; 63 | } 64 | 65 | .title { 66 | margin: 0; 67 | line-height: 1.15; 68 | font-size: 4rem; 69 | } 70 | 71 | .title, 72 | .description { 73 | text-align: center; 74 | } 75 | 76 | .description { 77 | line-height: 1.5; 78 | font-size: 1.5rem; 79 | } 80 | 81 | .code { 82 | background: #fafafa; 83 | border-radius: 5px; 84 | padding: 0.75rem; 85 | font-size: 1.1rem; 86 | font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, 87 | Bitstream Vera Sans Mono, Courier New, monospace; 88 | } 89 | 90 | .grid { 91 | display: flex; 92 | align-items: center; 93 | justify-content: center; 94 | flex-wrap: wrap; 95 | 96 | max-width: 800px; 97 | margin-top: 3rem; 98 | } 99 | 100 | .card { 101 | margin: 1rem; 102 | flex-basis: 45%; 103 | padding: 1.5rem; 104 | text-align: left; 105 | color: inherit; 106 | text-decoration: none; 107 | border: 1px solid #eaeaea; 108 | border-radius: 10px; 109 | transition: color 0.15s ease, border-color 0.15s ease; 110 | } 111 | 112 | .card:hover, 113 | .card:focus, 114 | .card:active { 115 | color: #0070f3; 116 | border-color: #0070f3; 117 | } 118 | 119 | .card h3 { 120 | margin: 0 0 1rem 0; 121 | font-size: 1.5rem; 122 | } 123 | 124 | .card p { 125 | margin: 0; 126 | font-size: 1.25rem; 127 | line-height: 1.5; 128 | } 129 | 130 | .logo { 131 | height: 1em; 132 | } 133 | 134 | @media (max-width: 600px) { 135 | .grid { 136 | width: 100%; 137 | flex-direction: column; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /lib/models/ships/model.ship.skin.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import ShareCfgModel from "../model.sharecfg.base"; 7 | import ShipSkinListItem from "./model.ship.skin.list.item"; 8 | import { dependsOn, exclude } from "../model.helpers"; 9 | 10 | @dependsOn([ "codes", "shipSkinsDialogue", "shipSkinsDialogueExtra" ]) 11 | export default class ShipSkin extends ShareCfgModel { 12 | @exclude() 13 | base: ShipSkinListItem; 14 | 15 | id: number; 16 | background: string; 17 | backgroundMusic: string; 18 | dialogue: { 19 | [key: string]: string 20 | } 21 | dialogueExtra: { 22 | [key: string]: string 23 | } 24 | 25 | constructor(id: number) { 26 | super(); 27 | 28 | this.base = new ShipSkinListItem(id); 29 | } 30 | 31 | async load(codes: any[], dialogue: any[], extras: any[]) { 32 | this.mixin(this.base); 33 | 34 | const d = dialogue.find(d => d.id == this.base.id); 35 | const e = extras.find(d => d.id == this.base.id); 36 | 37 | this.dialogue = (!d) 38 | ? null 39 | : Object.entries(SHIP_DIALOGUE_MAP) 40 | .reduce(mapDialogue(d, codes), {}); 41 | 42 | this.dialogueExtra = (!e) 43 | ? null 44 | : Object.entries(SHIP_DIALOGUE_MAP) 45 | .reduce(mapDialogue(e, codes), {}); 46 | } 47 | } 48 | 49 | function replaceNameCodes(str: string, codes: any) { 50 | return str.replace(NAMECODE_REGEX, function(match, p1) { 51 | const { code } = codes.find(c => c.id == parseInt(p1)); 52 | return code; 53 | }); 54 | } 55 | 56 | function mapDialogue(dialogue: any, codes: any) { 57 | return function (obj, [key, val]) { 58 | if (key == "main") { 59 | dialogue[key].split("|").forEach((text, index) => { 60 | obj[`idle${index + 1}`] = text != "nil" 61 | ? replaceNameCodes(text, codes) 62 | : null; 63 | }); 64 | } else { 65 | obj[val] = (typeof dialogue[key] === "string" && dialogue[key] > 0) 66 | ? replaceNameCodes(dialogue[key], codes) 67 | : null; 68 | } 69 | return obj; 70 | }; 71 | } 72 | 73 | const NAMECODE_REGEX = /\{namecode:(\d+)\}/g; 74 | 75 | const SHIP_DIALOGUE_MAP = { 76 | feeling1: "affinityDisappointed", 77 | feeling2: "affinityStranger", 78 | feeling3: "affinityFriendly", 79 | feeling4: "affinityLike", 80 | feeling5: "affinityLove", 81 | propose: "pledge", 82 | drop_descrip: "description", 83 | profile: "selfIntroduction", 84 | upgrade: "strengthening", 85 | detail: "details", 86 | unlock: "acquisition", 87 | login: "login", 88 | main: "idle", 89 | home: "return", 90 | mail: "mail", 91 | mission: "task", 92 | mission_complete: "taskComplete", 93 | expedition: "commission", 94 | touch: "touch", 95 | touch2: "specialTouch", 96 | headtouch: "headpat", 97 | skill: "skillActivate", 98 | battle: "startBattle", 99 | hp_warning: "lowHp", 100 | lose: "lose", 101 | win_mvp: "mvp" 102 | }; -------------------------------------------------------------------------------- /lib/database.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import mongoose from "mongoose"; 7 | 8 | const FileSchema = new mongoose.Schema({ 9 | name: { 10 | type: String, 11 | required: true 12 | }, 13 | hash: { 14 | type: String, 15 | required: true 16 | }, 17 | contents: { 18 | type: Buffer, 19 | required: true 20 | } 21 | }); 22 | 23 | let FileModel : mongoose.Model; 24 | try { 25 | FileModel = mongoose.model("File"); 26 | } catch { 27 | FileModel = mongoose.model("File", FileSchema); 28 | } 29 | 30 | const connectDB = async () => mongoose.connect(process.env.NIMI_MONGODB_HOST || 31 | "mongodb://localhost:27017", { useNewUrlParser: true }); 32 | 33 | /** 34 | * Interface that describes the model of a file entry in MongoDB 35 | */ 36 | export interface IFileSchema extends mongoose.Document { 37 | name: string, 38 | hash: string, 39 | contents: Buffer 40 | } 41 | 42 | /** 43 | * Creates a new file entry in the database. 44 | * @param name the name of the file 45 | * @param hash the hash identifier of the file, grab this from GitHub. 46 | * @param contents the buffered contents of the file. Recommended to use GZipped buffers here. 47 | */ 48 | export async function createFileEntry(name: string, hash: string, contents: Buffer): Promise { 49 | await connectDB(); 50 | const File = new FileModel({ name, hash, contents }); 51 | 52 | try { 53 | await File.save(); 54 | } catch (e) { 55 | throw new Error(e); 56 | } 57 | } 58 | 59 | /** 60 | * Updates a existing file entry in the database. Usually needed if the files has a new version somewhere. 61 | * @param name the name of the file. This needs to be consistent as this is used as a search term to the DB. 62 | * @param hash the new hash identifier of the file. New versions of the file gets a new hash so you want to update this. 63 | * @param contents the new (GZipped) buffered contents of the files. 64 | */ 65 | export async function updateFileEntry(name: string, hash:string, contents: Buffer): Promise { 66 | await connectDB(); 67 | const File: typeof FileModel = FileModel; 68 | 69 | try { 70 | const entry = await File.findOne({ name }); 71 | 72 | entry.update({}, { hash, contents }); 73 | entry.save(); 74 | } catch (e) { 75 | throw new Error(e); 76 | } 77 | } 78 | 79 | /** 80 | * Gets a file entry from the DB and returns the entry as a JavaScript object. 81 | * @param name the name of the file. 82 | * @returns the JavaScript object. This also contains the document id (_id). This is a instance of IFileModel as object. 83 | */ 84 | export async function getFileEntry(name: string) { 85 | await connectDB(); 86 | const File: typeof FileModel = FileModel; 87 | const entry: IFileSchema = await File.findOne({ name }); 88 | return entry?.toObject(); 89 | } 90 | 91 | /** 92 | * Deletes a file entry in the database. Useful if the file is deprecated on new versions of the file sets. 93 | * @param name the name of the file to remove. 94 | */ 95 | export async function deleteFileEntry(name: string) { 96 | await connectDB(); 97 | const File: typeof FileModel = FileModel; 98 | 99 | try { 100 | await File.findByIdAndDelete({ name }); 101 | } catch (e) { 102 | throw new Error(e); 103 | } 104 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | # Nimi 6 |  7 | 8 | Welcome aboard! Nimi is the unofficial API that returns JSON data from [Azur Lane](https://azurlane.yo-star.com/) and is always updated to the latest game version. Unlike most projects of the same mission, we're using a serverless approach for providing you these data, however, since we're iterating rapidly, there might be some bugs and of course, we change some stuff really fast so beware of maelstroms and icebergs, Captain! 9 | 10 | ### Compared to previous version 11 | 12 | Due to the stateless architecture of the new API, we are able to reach more audiences much more better than before. And thanks to the new API's architecture and [Vercel](https://vercel.com?utm_source=azur-lane-api&utm_campaign=oss), the service is now accessible anywhere in the world, we're no longer isolated in one region! You're always 80ms or 160ms away from the service. 13 | 14 | ### What's next? 15 | 16 | We're just getting started. We have a viewer coming up (and it's fully automated unlike the [Azur Lane Wiki](https://azurlane.koumakan.jp/Azur_Lane_Wiki)), and much more, so stay tuned! If you have any requests of your own, be sure to drop it by at the issues page. 17 | 18 | ### Motivation 19 | There aren't many data providers for this mobile game, so we decided to make one for the community. These allows aspiring developers to help out the community and opportunities like Discord bots or self-hosted websites with tools and viewers. 20 | 21 | Consider supporting our project as well so we can keep maintaining this project! A coffee a day gives us a happy day. 22 | 23 | [](https://ko-fi.com/W7W71CF9V) 24 | 25 | 26 | 27 | "Philosophy Sensei Z23" art by しるこ on pixiv 28 | 29 | 30 | 31 | ## Contributing 32 | 33 | We are very open to contributions such as feature suggestions and pull requests! There are things to take note before doing so however. 34 | 35 | Before you submit a pull request and to ensure you have a smooth time in developing and improving the project, use [Visual Studio Code](https://code.visualstudio.com/) or any other editor that supports syntax highlighting and linting. Make sure to install the recommended extensions as well. 36 | 37 | Our Continuous Integration configuration is contributor-neutral so the flow we use in this repository will also work on your fork, so make sure your code passes before submitting it upstream. 38 | 39 | If you found something that isnt right, want to ask a question, or have a suggestion you'd like to be added, then please do make a new issue. 40 | 41 | ## Credits 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Our project is powered by [Vercel](https://vercel.com?utm_source=azur-lane-api&utm_campaign=oss)! We host the project there and if you have a upcoming project, you should consider choosing Vercel as your host. 50 | 51 | This API is Copyright © Nathan Alo and Ayane Satomi. Licensed under GNU General Public License v3.0. 52 | 53 | Contains code from [Aya](https://github.com/ClarityCafe/Aya). Aya's components are Copyright © Ayane Satomi, Michael Mitchell, et al. Licensed under MIT. 54 | 55 | Azur Lane, the game, and all its assets are Copyright © Yostar. The developers and contributors are no way affiliated with the game, the company, nor its partners. 56 | 57 | ### Notes 58 | 59 | While this project is open source under GNU General Public License, commercial use of this API is prohibited. This clause is non-negotiable. 60 | -------------------------------------------------------------------------------- /lib/resolvers/resolver.base.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Directory from "../github/github.directory"; 7 | import { IModel } from "lib/models/model.base"; 8 | import Path from "path"; 9 | import Repository from "../github/github.repository"; 10 | import snappy from "snappy"; 11 | import util from "util"; 12 | import { IFileSchema, createFileEntry, getFileEntry, updateFileEntry } from "lib/database"; 13 | 14 | const compress = util.promisify(snappy.compress); 15 | const uncompress = util.promisify(snappy.uncompress); 16 | 17 | export type ResolverRegion = 18 | | "en" 19 | | "jp" 20 | | "cn" 21 | | "kr" 22 | | "tw"; 23 | 24 | /** 25 | * The base class for all resolvers. Resolvers manage obtaining and caching files from the remote repository. 26 | */ 27 | export default abstract class Resolver { 28 | path: string; 29 | lang: string; 30 | repo: Repository; 31 | directory: Directory; 32 | cache: Map; 33 | 34 | /** 35 | * @param path The path relative from the repository's root 36 | * @param lang The language 37 | * @param repo The GitHub repository 38 | */ 39 | constructor(path: string, lang: ResolverRegion, repo: Repository) { 40 | this.path = path; 41 | this.lang = lang.toUpperCase(); 42 | this.repo = repo; 43 | this.directory = null; 44 | this.cache = new Map(); 45 | } 46 | 47 | get initialized() : boolean { 48 | return this.directory !== null; 49 | } 50 | 51 | /** 52 | * Initializes this repository by sloading the directory and retrieving its files 53 | */ 54 | async init() : Promise { 55 | this.directory = await this.repo.getDirectory( 56 | Path.join(this.lang, this.path).replace(/\\/g, "/") 57 | ); 58 | } 59 | 60 | /** 61 | * Resolves a model's loader method and passes back resolved values to its arguments 62 | * @param loader A model's loader method 63 | */ 64 | abstract resolve(model: IModel) : Promise 65 | 66 | /** 67 | * Retrieves a file from cache or downloads the file from the repository if it doesn't exist. 68 | * @param file The file name to retrieve. 69 | * @param directory The directory to lookup from. 70 | */ 71 | async getFile(file: string, directory = this.directory) : Promise { 72 | if (!this.initialized) 73 | throw new Error("Remote has not been initialized"); 74 | 75 | const path = Path.join(this.lang, this.path, file).replace(/\\/g, "/"); 76 | const remote = directory.getFile(file); 77 | 78 | if (remote === null) 79 | throw new Error(`${path} is not a file or is not found.`); 80 | 81 | const useMongoDB = process.env.NIMI_MONGODB_HOST && process.env.NODE_ENV !== "development"; 82 | 83 | // First, check if we have the file cached in memory. 84 | if (this.cache.has(file)) 85 | return this.cache.get(file); 86 | 87 | // If we don't have it, check if it is cached in our database. 88 | let cached: IFileSchema; 89 | if (useMongoDB) { 90 | cached = (await getFileEntry(file)); 91 | if (cached?.hash === remote.sha) { 92 | const raw = (await uncompress(Buffer.from(cached.contents.buffer), { asBuffer: false })); 93 | const data = JSON.parse(raw); 94 | this.cache.set(file, data); 95 | return data; 96 | } 97 | } 98 | 99 | // If we really don't have it or we have an outdated entry, obtain it from GitHub. 100 | const download = await directory.download(file); 101 | if (useMongoDB) { 102 | if (cached?.hash === undefined) 103 | createFileEntry(file, remote.sha, await compress(download)); 104 | else 105 | updateFileEntry(file, remote.sha, await compress(download)); 106 | } 107 | 108 | const data = JSON.parse(download); 109 | this.cache.set(file, data); 110 | return data; 111 | } 112 | } -------------------------------------------------------------------------------- /lib/resolvers/resolver.sharecfg.base.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import Directory from "lib/github/github.directory"; 7 | import { IModel } from "lib/models/model.base"; 8 | import { MODEL_DEPENDS_KEY } from "lib/constants"; 9 | import Repository from "../github/github.repository"; 10 | import path from "path"; 11 | import Resolver, { ResolverRegion } from "./resolver.base"; 12 | 13 | type Transformer = (o: unknown) => unknown; 14 | 15 | /** 16 | * A resolver that resolves files from the `/sharecfg` directory 17 | */ 18 | export default class ShareCfgResolver extends Resolver { 19 | dependencies: Map; 20 | subDirectories: Map; 21 | 22 | /** 23 | * 24 | * @param lang the language 25 | * @param repo the repository to obtain data from 26 | */ 27 | constructor(lang: ResolverRegion, repo: Repository) { 28 | super("/sharecfg", lang, repo); 29 | 30 | this.dependencies = new Map(); 31 | this.subDirectories = new Map(); 32 | } 33 | 34 | static DEFAULT_TRANSFORMER(obj: { all: number[] }) : unknown { 35 | if (obj.all) 36 | delete obj.all; 37 | 38 | return Object.values(obj); 39 | } 40 | 41 | /** 42 | * Initializes this resolver. This is also where file names are mapped onto strings 43 | * for dependency resolution. 44 | */ 45 | async init() : Promise { 46 | this.add("ships", "ship_data_template.json"); 47 | this.add("shipStats", "ship_data_statistics.json"); 48 | this.add("shipSkins", "ship_skin_template.json", true); 49 | this.add("shipSkinsDialogue", "ship_skin_words.json"); 50 | this.add("shipSkinsDialogueExtra", "ship_skin_words_extra.json"); 51 | this.add("shipGroups", "ship_data_group.json"); 52 | this.add("shipBreakouts", "ship_data_breakout.json"); 53 | this.add("shipRetrofits", "ship_data_trans.json"); 54 | this.add("shipRetrofitTasks", "transform_data_template.json"); 55 | this.add("shipBlueprints", "ship_data_blueprint.json"); 56 | this.add("shipConstruction", "ship_data_create_material.json"); 57 | 58 | this.add("equip", "equip_data_template.json", true); 59 | this.add("equipStats", "equip_data_statistics.json", true); 60 | this.add("equipSkins", "equip_skin_template.json"); 61 | this.add("equipSkinThemes", "equip_skin_theme_template.json"); 62 | 63 | this.add("skills", "skill_data_template.json"); 64 | 65 | this.add("items", "item_data_statistics.json"); 66 | this.add("itemChatFrames", "item_data_chat.json"); 67 | this.add("itemIconFrames", "item_data_frames.json"); 68 | this.add("itemPlayerResources", "player_resource.json"); 69 | this.add("furniture", "furniture_data_template.json"); 70 | 71 | this.add("lang", "gameset_language_client.json", false, (o: unknown) => o); 72 | this.add("tasks", "task_data_template.json"); 73 | this.add("codes", "name_code.json"); 74 | this.add("monthlySignIn", "activity_month_sign.json"); 75 | 76 | this.add("social", "activity_ins_template.json"); 77 | this.add("socialNpc", "activity_ins_npc_template.json"); 78 | this.add("socialNpcGroup", "activity_ins_ship_group_template.json"); 79 | 80 | this.add("meowfficers", "commander_data_template.json"); 81 | this.add("meowfficerSkills", "commander_skill_template.json"); 82 | 83 | this.add("commissions", "collection_template.json"); 84 | this.add("research", "technology_data_template.json"); 85 | 86 | await super.init(); 87 | } 88 | 89 | /** 90 | * Map an argument type to a file for dependency resolving 91 | * @param type The argument type 92 | * @param file The file to be resolved 93 | * @param hasSubList Whether the file references other files 94 | * @param transform A function called to modify the resolved object before being passed 95 | */ 96 | add(type: string, file: string, hasSubList = false, transform: Transformer = ShareCfgResolver.DEFAULT_TRANSFORMER) { 97 | this.dependencies.set(type, [file, hasSubList, transform]); 98 | } 99 | 100 | async resolve(model: IModel) : Promise { 101 | const dependencies : string[] = Reflect.getOwnMetadata(MODEL_DEPENDS_KEY, (model).constructor); 102 | return await Promise.all(dependencies?.map(async (k: string) => await this.getFile(k)) ?? []); 103 | } 104 | 105 | /** 106 | * Resolve a dependency 107 | * @param type The dependency name 108 | */ 109 | async getFile(type: string) : Promise { 110 | if (!this.dependencies.has(type)) 111 | throw new Error(`Dependency is not registered > ${this.constructor.name}:${type}`); 112 | 113 | const [ file, hasSubList, transform ] = this.dependencies.get(type) ?? []; 114 | 115 | if (!hasSubList) 116 | return transform(await super.getFile(file)); 117 | 118 | const { subList } = await super.getFile(file); 119 | 120 | let subDirectory : Directory; 121 | 122 | if (this.subDirectories.has(file)) 123 | { 124 | subDirectory = this.subDirectories.get(file); 125 | } 126 | else 127 | { 128 | const directoryName = path.parse(file).name + "_sublist"; 129 | subDirectory = await this.directory.getDirectory(directoryName); 130 | this.subDirectories.set(file, subDirectory); 131 | } 132 | 133 | const data = await Promise.all( 134 | subList.map(async (f: string) => 135 | super.getFile(f + ".json", subDirectory) 136 | ) 137 | ); 138 | 139 | return transform(data.reduce((prev, curr) => Object.assign(prev, curr), {})); 140 | } 141 | } -------------------------------------------------------------------------------- /lib/models/ships/model.ship.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { SHIP_ATTR_TYPE } from "lib/constants"; 7 | import ShareCfgModel from "../model.sharecfg.base"; 8 | import ShipListItem from "./model.ship.list.item"; 9 | import Skill from "../shared/model.skill"; 10 | import { dependsOn, exclude } from "../model.helpers"; 11 | 12 | type ShipGroupDescriptionItem = [string, [ShipDescriptionAction, any]] 13 | 14 | enum ShipExchangeLocation { 15 | Core = "core", 16 | Medal = "medal", 17 | Munitions = "munitions", 18 | } 19 | 20 | enum ShipDescriptionAction { 21 | None, 22 | Shop = "SHOP", 23 | Research = "SHIPBLUEPRINT", 24 | Collection = "COLLECTSHIP", 25 | Checkpoint = "LEVEL", 26 | Construction = "GETBOAT", 27 | } 28 | 29 | interface ShipAcquisitionDetails { 30 | task: string, 31 | chapter: number, 32 | stage: number, 33 | event: string, 34 | exchange: ShipExchangeLocation, 35 | collection: boolean, 36 | attributes: { [key: string]: number }; 37 | construction: { 38 | light: boolean, 39 | heavy: boolean, 40 | special: boolean, 41 | limited: boolean, 42 | research: boolean 43 | } 44 | } 45 | 46 | @dependsOn([ "ships", "shipBreakouts" ]) 47 | export default class Ship extends ShareCfgModel { 48 | @exclude() 49 | base: ShipListItem; 50 | 51 | ammoCount: number; 52 | armorType: number; 53 | equipment: any; 54 | attributes: any; 55 | skills: Skill[]; 56 | breakouts: any[]; 57 | acquisition: ShipAcquisitionDetails; 58 | 59 | constructor(groupId: number, breakoutLevel: number) { 60 | super(); 61 | 62 | this.base = new ShipListItem(groupId, breakoutLevel); 63 | } 64 | 65 | async load(ships: any[], breakouts: any[]): Promise { 66 | this.mixin(this.base); 67 | 68 | const { ship, stats, group } = this.base.item; 69 | 70 | this.ammoCount = ship.ammo; 71 | this.skills = ship.buff_list.map((id: number) => new Skill(id)); 72 | 73 | this.breakouts = breakouts 74 | .filter(b => ships.filter(s => s.group_type == this.base.groupId) 75 | .map(s => s.id).includes(b.id)) 76 | .map(b => { 77 | return { 78 | description: (b.breakout_view != "N/A") 79 | ? b.breakout_view.replace(/\//g, " / ") 80 | : b.breakout_view, 81 | level: b.level, 82 | cost: { 83 | gold: b.use_gold, 84 | ship: b.use_char_num 85 | } 86 | }; 87 | }); 88 | 89 | this.armorType = stats.armor_type; 90 | this.equipment = Object.keys(ship) 91 | .filter(key => /equip_\d/.test(key)) 92 | .reduce((obj, key, idx) => { 93 | const slot = idx + 1; 94 | obj[slot] = {}; 95 | obj[slot].types = ship[key]; 96 | 97 | if (stats.equipment_proficiency[idx]) 98 | obj[slot].proficiency = stats.equipment_proficiency[idx]; 99 | 100 | return obj; 101 | }, {}); 102 | 103 | this.attributes = Object.entries(SHIP_ATTR_TYPE) 104 | .reduce((obj, entry) => { 105 | const [key, val] = entry; 106 | obj[val] = stats.attrs[parseInt(key)]; 107 | return obj; 108 | }, { oxy: ship.oxy_max }); 109 | 110 | this.acquisition = group.description.reduce(( 111 | output : ShipAcquisitionDetails, 112 | [text, [action, args]] : ShipGroupDescriptionItem 113 | ) => { 114 | text = text.trim(); 115 | 116 | switch (action) { 117 | case ShipDescriptionAction.Shop: 118 | if (args.warp) 119 | output.exchange = ACQUISITION_WARP[args.warp]; 120 | break; 121 | 122 | case ShipDescriptionAction.Collection: 123 | output.collection = true; 124 | break; 125 | 126 | case ShipDescriptionAction.Research: 127 | output.construction.research = true; 128 | break; 129 | 130 | case ShipDescriptionAction.Construction: 131 | if (args.page == 3) 132 | output.exchange = ShipExchangeLocation.Medal; 133 | 134 | const types = text.match(REGEX_CONSTRUCT); 135 | if (types !== null) { 136 | for (const type of [...types]) 137 | output.construction[type.toLowerCase()] = true; 138 | } 139 | break; 140 | 141 | case ShipDescriptionAction.Checkpoint: 142 | const [, chapter, stage] = text.match(REGEX_CHECKPOINT); 143 | output.chapter = parseInt(chapter); 144 | output.stage = parseInt(stage); 145 | break; 146 | 147 | default: 148 | if (REGEX_EVENT.test(text)) 149 | output.event = text.match(REGEX_EVENT)[1]; 150 | 151 | // For some reason this is inconsistent with how all events are named so far 152 | if (text == "The War God's Return") 153 | output.event = text; 154 | 155 | output.construction.limited = text.includes("Limited"); 156 | output.task = ACQUISITION_TASK[text]; 157 | break; 158 | } 159 | 160 | return output; 161 | }, ACQUISITION_DEFAULTS); 162 | } 163 | } 164 | 165 | const REGEX_CONSTRUCT = /(light|heavy|special)/gi; 166 | const REGEX_CHECKPOINT = /(\d+)-(\d+)/; 167 | const REGEX_EVENT = /Event: (.+)/; 168 | 169 | const ACQUISITION_DEFAULTS = { 170 | chapter: null, 171 | stage: null, 172 | task: null, 173 | event: null, 174 | exchange: null, 175 | collection: false, 176 | construction: { 177 | light: false, 178 | heavy: false, 179 | special: false, 180 | limited: false, 181 | research: false 182 | } 183 | }; 184 | 185 | const ACQUISITION_TASK = { 186 | "CBT Reward": "closedBetaParticipant", 187 | "Weekly Mission": "weeklyMission", 188 | "Monthly Sign-in": "monthlySignIn", 189 | "Hidden Mission:Im-paws-ible quest": "akashiMissions" 190 | }; 191 | 192 | const ACQUISITION_WARP = { 193 | "sham": ShipExchangeLocation.Core, 194 | "supplies": ShipExchangeLocation.Munitions 195 | }; -------------------------------------------------------------------------------- /lib/models/model.base.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 - 2020 Nathan Alo, Ayane Satomi, et al. 3 | * Licensed under the GNU General Public License v3 4 | * See LICENSE for details. 5 | */ 6 | import { MODEL_EXCLUDE_KEY } from "lib/constants"; 7 | import Repository from "lib/github/github.repository"; 8 | import { exclude } from "./model.helpers"; 9 | import Resolver, { ResolverRegion } from "../resolvers/resolver.base"; 10 | import "reflect-metadata"; 11 | 12 | type ModelResolverOptions = { 13 | repo: string, 14 | token: string, 15 | region: ResolverRegion, 16 | } 17 | 18 | export interface IModel { 19 | load(...args: unknown[]) : Promise; 20 | loadComplete() : void; 21 | run(raw?: boolean, resolver?: Resolver) : Promise; 22 | serialize() : any; 23 | setResolverDefaults(token: string, repo: string, region: ResolverRegion) : void; 24 | resolve(resolver: Resolver) : Promise 25 | mixin(model: IModel) : void; 26 | } 27 | 28 | /** 29 | * The Model class is the base class where all deriverative model classes should 30 | * inherit from. 31 | * 32 | * All Model-derived classes are required to implement a load method to load its 33 | * properties to properly inject itself on the endpoints. 34 | */ 35 | export default abstract class Model implements IModel { 36 | resolver: { new(lang: string, repo: Repository): T }; 37 | 38 | @exclude() 39 | resolverOptions?: ModelResolverOptions; 40 | 41 | constructor(resolver: ({ new(lang: string, repo: Repository): T })) { 42 | this.resolver = resolver; 43 | } 44 | 45 | /** 46 | * Loads any required properties for the deriverative model. 47 | * Anything loaded by this method will be accessible later on during instantiation. 48 | * @param args the arguments passed by the resolvers. 49 | */ 50 | // eslint-disable-next-line @typescript-eslint/no-unused-vars 51 | async load(...args: unknown[]) : Promise {} 52 | 53 | /** 54 | * Called after all nested Models' dependencies are resolved. 55 | * Useful if you require certain properties only available after it being resolved. 56 | */ 57 | loadComplete() : void {} 58 | 59 | /** 60 | * Runs the entire lifecycle of this model. 61 | * @param raw Whether to return itself or the serialized version 62 | * @param resolver The resolver to use for model serialization 63 | */ 64 | async run(raw = false, resolver: Resolver = null) : Promise { 65 | // Instantiate the resolver only when we don't supply one 66 | if (!resolver) { 67 | const [ owner, repoName ] = this.resolverOptions?.repo.split("/"); 68 | const repo = new Repository(this.resolverOptions?.token, owner, repoName); 69 | resolver = new this.resolver(this.resolverOptions?.region, repo); 70 | 71 | await resolver.init(); 72 | } 73 | 74 | // The first resolve resolves models instanced in the constructor 75 | // making the properties ready for use in the load method 76 | await this.resolve(resolver); 77 | await this.load(...(await resolver.resolve(this))); 78 | 79 | // The second resolve resolves models instanced in the load method 80 | await this.resolve(resolver); 81 | 82 | this.loadComplete(); 83 | return raw ? this : this.serialize(); 84 | } 85 | 86 | setResolverDefaults(token: string, repo: string, region: ResolverRegion) { 87 | this.resolverOptions = { repo, token, region }; 88 | } 89 | 90 | /** 91 | * Serializes public properties including those nested inside arrays and objects into an Object. 92 | */ 93 | serialize() : Object { 94 | const output = {}; 95 | 96 | for (const prop of Object.getOwnPropertyNames(this)) { 97 | if (Reflect.getMetadata(MODEL_EXCLUDE_KEY, this, prop) ?? false) 98 | continue; 99 | 100 | if (Array.isArray(this[prop])) { 101 | const serialized = []; 102 | 103 | for (const nested of this[prop]) { 104 | serialized.push( 105 | (nested instanceof Model) 106 | ? nested.serialize() 107 | : nested 108 | ); 109 | } 110 | 111 | output[prop] = serialized; 112 | } 113 | else if (typeof this[prop] === "object") { 114 | output[prop] = {}; 115 | 116 | for (const nested of Object.getOwnPropertyNames(this[prop])) { 117 | output[prop][nested] = (this[prop][nested] instanceof Model) 118 | ? this[prop][nested].serialize() 119 | : this[prop][nested]; 120 | } 121 | } 122 | else 123 | output[prop] = this[prop]; 124 | } 125 | 126 | return output; 127 | } 128 | 129 | /** 130 | * Resolves nested Models that was instanced inside the parent including those nested in objects and arrays. 131 | * @param resolver The resolver to use. 132 | */ 133 | async resolve(resolver: Resolver) : Promise { 134 | for (const prop of Object.getOwnPropertyNames(this)) { 135 | if (this[prop] instanceof Model) 136 | this[prop] = await (this[prop] as unknown as IModel)?.run(true, resolver); 137 | 138 | if (Array.isArray(this[prop])) { 139 | const resolved = []; 140 | 141 | for (const nested of this[prop]) { 142 | resolved.push( 143 | (nested instanceof Model) 144 | ? await (nested as unknown as IModel).run(true, resolver) 145 | : nested 146 | ); 147 | } 148 | 149 | this[prop] = resolved; 150 | } 151 | 152 | if (!Array.isArray(this[prop]) && typeof this[prop] === "object") { 153 | for (const nested of Object.getOwnPropertyNames(this[prop])) { 154 | if (this[prop][nested] instanceof Model) 155 | this[prop][nested] = await (this[prop][nested] as unknown as IModel).run(true, resolver); 156 | } 157 | } 158 | } 159 | } 160 | 161 | /** 162 | * Applies the provided model to this instance. 163 | * @param model The model to be applied. 164 | */ 165 | mixin(model: Model) { 166 | for (const prop of Object.getOwnPropertyNames(model)) { 167 | this[prop] = model[prop]; 168 | if (Reflect.getMetadata(MODEL_EXCLUDE_KEY, model, prop) ?? false) 169 | Reflect.defineMetadata(MODEL_EXCLUDE_KEY, true, this, prop); 170 | } 171 | } 172 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . --------------------------------------------------------------------------------
24 | Nimi is an unofficial API for Azur Lane based on Next.js. 25 |
Find in-depth information about Nimi's API.
Help us make Nimi better by sharing your ideas in GitHub.
39 | Check if the API is currently available 40 | (PS: you can change this too if you plan to run your own version). 41 |
2 | 3 |
26 | 27 | "Philosophy Sensei Z23" art by しるこ on pixiv 28 | 29 |
45 | 46 |