Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

Commit

Permalink
Fully test the items endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-1 committed Apr 24, 2022
1 parent f361b14 commit befd253
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typed-hypixel-api",
"version": "1.2.0",
"version": "1.3.0",
"main": "build/index.js",
"types": "build/index.d.js",
"repository": "https://github.com/skyblockstats/typed-hypixel-api.git",
Expand Down
166 changes: 151 additions & 15 deletions src/responses/resources/skyblock/items.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,89 @@
import { SkyBlockSlayerBosses } from '../../skyblock/_profile_member'

type EssenceType = 'DIAMOND'
type EssenceType =
| 'DIAMOND'
| 'WITHER'
| 'GOLD'
| 'CRIMSON'
| 'UNDEAD'
| 'DRAGON'
| 'SPIDER'
| 'ICE'
type GemstoneType =
| 'AMETHYST'
| 'JASPER'
| 'RUBY'
| 'JADE'
| 'AMBER'
| 'SAPPHIRE'
| 'TOPAZ'
| 'OPAL'

export interface SkyBlockItemsResponse {
success: true
lastUpdated: number
items: ({
material: string
/** A record of enchantment ids like `counter_strike` to their default level. */
enchantments?: Record<string, number>
durability?: number
item_durability?: -1
name: string
glowing?: boolean
furniture?: string
category?: string
/** If the item is a floating crystal, this will be present. */
crystal?:
| 'FISHING'
| 'FARM'
| 'RESOURCE_REGENERATOR'
| 'FOREST_ISLAND'
| 'WHEAT_ISLAND'
| 'WOODCUTTING'
| 'DESERT_ISLAND'
| 'MITHRIL'
| 'NETHER_WART_ISLAND'
tier?: string
unstackable?: boolean
/**
* Almost no items have this. Formatting codes here look like
* `%%gray%%`.
*/
description?: string
unstackable?: true
can_have_attributes?: true
salvageable_from_recipe?: true
salvages?: (
| {
essence_type: EssenceType
amount: number
}
| {
item_id: string
amount: number
}
)[]
stats?: {
DAMAGE?: number
STRENGTH?: number
DEFENSE?: Number
DEFENSE?: number
HEALTH?: number
MINING_FORTUNE?: number
WALK_SPEED?: number
MAGIC_FIND?: number
INTELLIGENCE?: number
WEAPON_ABILITY_DAMAGE?: number
CRITICAL_DAMAGE?: number
CRITICAL_CHANCE?: number
SEA_CREATURE_CHANCE?: number
FEROCITY?: number
BREAKING_POWER?: number
MINING_SPEED?: number
PET_LUCK?: number
ABILITY_DAMAGE_PERCENT?: number
TRUE_DEFENSE?: number
ATTACK_SPEED?: number
}
ability_damage_scaling?: number
/**
* The number of coins that the player gets from selling the item to
* an NPC.
Expand All @@ -36,20 +97,41 @@ export interface SkyBlockItemsResponse {
essence_type: EssenceType
amount: number
}
upgrade_costs?: [
{
essence_type: EssenceType
amount: number
}
][]
upgrade_costs?: (
| {
essence_type: EssenceType
amount: number
}
| {
item_id: string
amount: number
}
)[][]
prestige?: {
/** An item id like BURNING_AURORA_LEGGINGS. */
item_id: string
costs: (
| {
essence_type: EssenceType
amount: number
}
| {
item_id: string
amount: number
}
)[]
}
gemstone_slots?: {
slot_type: 'AMETHYST' | 'COMBAT'
slot_type: GemstoneType | 'UNIVERSAL' | 'MINING' | 'COMBAT' | 'DEFENSIVE' | 'OFFENSIVE'
costs?: (
| {
coins: number
}
| {
item_id: `FINE_${string}_GEM`
item_id:
| `FINE_${GemstoneType}_GEM`
| `FLAWLESS_${GemstoneType}_GEM`
| 'GEMSTONE_CHAMBER'
amount: number
}
)[]
Expand All @@ -65,15 +147,36 @@ export interface SkyBlockItemsResponse {
}
}
tiered_stats?: {
WALK_SPEED: number[]
DEFENSE: number[]
DAMAGE?: number[]
STRENGTH?: number[]
DEFENSE?: number[]
HEALTH?: number[]
MINING_FORTUNE?: number[]
WALK_SPEED?: number[]
MAGIC_FIND?: number[]
INTELLIGENCE?: number[]
WEAPON_ABILITY_DAMAGE?: number[]
CRITICAL_DAMAGE?: number[]
CRITICAL_CHANCE?: number[]
SEA_CREATURE_CHANCE?: number[]
FEROCITY?: number[]
BREAKING_POWER?: number[]
MINING_SPEED?: number[]
PET_LUCK?: number[]
ABILITY_DAMAGE_PERCENT?: number[]
TRUE_DEFENSE?: number[]
ATTACK_SPEED?: number[]
}
requirements?: {
/** If present, you need a specific level in a dungeon. */
dungeon?: {
type: 'CATACOMBS'
level: number
}
dungeon_completion?: {
type: 'CATACOMBS'
tier: number
}
/**
* If present, a reputation with one of the factions from
* the nether is required.
Expand All @@ -89,17 +192,50 @@ export interface SkyBlockItemsResponse {
slayer_boss_type: SkyBlockSlayerBosses
level: number
}
skill?: {
/** A skill id in all caps, like "FISHING". */
type: string
level: number
}
trophy_fishing_reward?: {
reward: 'BRONZE' | 'SILVER' | 'GOLD' | 'DIAMOND'
}
heart_of_the_mountain?: {
tier: number
}
collection?: {
/** A collection id, in all caps. */
collection_id: string
required_tier: number
}
target_practice?: {
mode: 'I' | 'II' | 'III'
}
}
dungeon_item?: boolean
/**
* If this is 'COOP', that means the item cannot be transferred to anyone outside the coop.
* If this is 'COOP', that means the item cannot be transferred to
* anyone outside the coop. If it's `SOLO`, it can't even be given to
* anyone in the coop.
*/
soulbound?: 'COOP'
soulbound?: 'COOP' | 'SOLO'
salvage?: {
item_id: string
amount: number
}
/**
* Whether the item can be put on display in the museum.
* https://hypixel-skyblock.fandom.com/wiki/Museum
*/
museum?: true
gear_score?: number
/**
* If this is present that means the item is an island spawner, its
* value is the uppercase id of it like `MINING_FOREST`. Note that this
* is *not* the same as the `id` field, for example in this case the
* `id` is `ROOFED_FOREST_ISLAND`.
* */
private_island?: string
id: string
} & (
| {
Expand Down
10 changes: 7 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@ const startTime = Date.now();
await testData('SkyBlockNewsResponse', await request('skyblock/news', { key: process.env.API_KEY }, true))
await testData('SkyBlockBazaarResponse', await request('skyblock/bazaar', {}, true))

let itemsResponse = await request('resources/skyblock/items', {}, true)
// we have to do this otherwise typescript gets mad :(
itemsResponse.data.items = itemsResponse.data.items.slice(0, 1000)
await testData('SkyBlockItemsResponse', itemsResponse)
const itemsResponse = await request('resources/skyblock/items', {}, true)
const originalItems = itemsResponse.data.items
for (let i = 0; i < originalItems.length / 1000; i++) {
itemsResponse.data.items = originalItems.slice(i * 1000, (i + 1) * 1000)
await testData('SkyBlockItemsResponse', itemsResponse)
}


await testData('PlayerDataResponse', await request('player', {
uuid: 'ed32a0660fc948378dcf8ed717d1188c',
Expand Down

0 comments on commit befd253

Please sign in to comment.