Skip to content

Commit

Permalink
Merge pull request #70 from glaciyan/fix-schema
Browse files Browse the repository at this point in the history
Fix import schema to include completed Items
  • Loading branch information
glaciyan authored Feb 17, 2022
2 parents bf81975 + d291c97 commit c2804db
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gscale",
"license": "MIT",
"version": "2.3.0",
"version": "2.3.1",
"scripts": {
"pre": "npm run gen:version",
"dev": "npm run pre && vite",
Expand Down
31 changes: 17 additions & 14 deletions src/lib/data/contracts/IItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ import { INamed } from "./INamed";
export interface IItem extends INamed {
rarity: number;
groupId?: ItemGroupsKey;
category:
| "boss"
| "common"
| "none"
| "weaponCommon"
| "weaponAscension"
| "local"
| "weekly"
| "book"
| "special_talent"
| "weapon_leveling"
| "character_leveling"
| "gem"
| "currency";
category: typeof Categories[-1];
}

export const Categories = [
"boss",
"common",
"none",
"weaponCommon",
"weaponAscension",
"local",
"weekly",
"book",
"special_talent",
"weapon_leveling",
"character_leveling",
"gem",
"currency",
] as const;
51 changes: 48 additions & 3 deletions src/lib/data/keys/ItemGroupsKey.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@

type ItemGroupsKey = "unknown" | "sentinel_gear" | "prism" | "oni_mask" | "coral" | "claw" | "narukami" | "spectral" | "light" | "transience" | "handguard" | "elegance" | "pyro_gem" | "geo_gem" | "cryo_gem" | "electro_gem" | "hydro_gem" | "anemo_gem" | "traveler_gem" | "scroll" | "arrowhead" | "treasure_hoarder_insignia" | "mask" | "fatui_insignia" | "nectar" | "slime" | "ballad" | "freedom" | "gold" | "resistance" | "diligence" | "prosperity" | "chaos" | "horn" | "bone_shard" | "sacrificial_knife" | "mist_grass" | "ley_line" | "dandelion_gladiator" | "decarabians" | "aerosiderite" | "guyun" | "mist_elixir" | "wolf_tooth";
export default ItemGroupsKey;
export const PhysicalItemGroupsKey = [
"unknown",
"sentinel_gear",
"prism",
"oni_mask",
"coral",
"claw",
"narukami",
"spectral",
"light",
"transience",
"handguard",
"elegance",
"pyro_gem",
"geo_gem",
"cryo_gem",
"electro_gem",
"hydro_gem",
"anemo_gem",
"traveler_gem",
"scroll",
"arrowhead",
"treasure_hoarder_insignia",
"mask",
"fatui_insignia",
"nectar",
"slime",
"ballad",
"freedom",
"gold",
"resistance",
"diligence",
"prosperity",
"chaos",
"horn",
"bone_shard",
"sacrificial_knife",
"mist_grass",
"ley_line",
"dandelion_gladiator",
"decarabians",
"aerosiderite",
"guyun",
"mist_elixir",
"wolf_tooth",
] as const;
type ItemGroupsKey = typeof PhysicalItemGroupsKey[-1];
export default ItemGroupsKey;
16 changes: 16 additions & 0 deletions src/lib/types/GDataFileFormat.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { z } from "zod";
import { Categories } from "../data/contracts/IItem";
import { PhysicalItemGroupsKey } from "../data/keys/ItemGroupsKey";
import { Build } from "../offlineDatabase/db";

export class GDataFileFormat {
Expand Down Expand Up @@ -53,6 +55,20 @@ const schema = z.object({
goal: z.number(),
upgraded: z.boolean(),
}),
completed: z
.array(
z.object({
item: z.object({
name: z.string(),
normalizedName: z.string(),
rarity: z.number(),
groupId: z.enum(PhysicalItemGroupsKey).optional(),
category: z.enum(Categories),
}),
amount: z.number(),
})
)
.optional(),
})
),
}),
Expand Down

1 comment on commit c2804db

@vercel
Copy link

@vercel vercel bot commented on c2804db Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.