Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/locales/lib/human/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"search_quests": "Search Quests",
"search_lures": "Search Lures",
"search_invasions": "Search Invasions",
"search_incidents": "Search Pokestop Events",
"sm": "sm",
"md": "md",
"lg": "lg",
Expand Down Expand Up @@ -362,6 +363,8 @@
"lure": "Lure",
"quest": "Quest",
"invasion": "Invasion",
"incident": "Pokestop Events",
"incident_unknown": "Pokestop Event #{{id}}",
"nest": "Nest",
"pokestop": "Pokestop",
"team": "Team",
Expand Down Expand Up @@ -396,8 +399,12 @@
"slider_pvp": "Ranks",
"profile_no": "Profile",
"template": "Template",
"default_template": "Default",
"gender": "Gender",
"gender_3": "Genderless",
"clean": "Clean",
"edit": "Edit",
"summary": "Summary",
"all_forms": "All Forms",
"pvp_entry": "PVP Entry",
"no_iv": "Incl. No IV",
Expand Down
6 changes: 6 additions & 0 deletions packages/types/lib/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ export interface Webhook {
host: string
port: number
poracleSecret: string
/**
* Which Poracle API to use. `auto` (the default) uses the PoracleNG v2 API
* when the server's `/openapi.json` lists the v2 routes, and v1 otherwise
* (PoracleJS, older PoracleNG). `v1` and `v2` skip the check.
*/
apiVersion?: 'auto' | 'v1' | 'v2'
addressFormat?: string
/** Base URL of the geocoding backend. Used for both providers. */
nominatimUrl?: string
Expand Down
193 changes: 29 additions & 164 deletions packages/types/lib/poracle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export interface PoracleActiveHours {
day: number
hours: string
mins: string
/** Hours between repeats; set (> 0) on a range entry. */
step?: number
end_hours?: number
end_mins?: number
}

export interface PoracleProfile<Parsed extends boolean = true> {
Expand All @@ -40,177 +44,37 @@ export interface PoracleProfile<Parsed extends boolean = true> {
name: string
}

export interface PoracleGym {
uid: number
id: string
profile_no: number
ping: string
clean: boolean
distance: number
template: string
team: number
slot_changes: number
gym_id: string
description: string
/** A tracking rule as PoracleNG v2 returns it (`null` = any). */
export type PoracleRule = {
uid?: number
description?: string
}

export interface PoracleRaid {
uid: number
id: string
profile_no: number
ping: string
exclusive: boolean
level: number
clean: boolean
distance: number
template: string
team: number
rsvp_changes: number
gym_id: string
form: number
move: number
pokemon_id: number
description: string
}

export interface PoracleEgg {
uid: number
id: string
profile_no: number
ping: string
exclusive: boolean
level: number
clean: boolean
distance: number
template: string
team: number
rsvp_changes: number
gym_id: string
description: string
}

export interface PoracleInvasion {
uid: number
id: string
profile_no: number
ping: string
clean: boolean
gender: number
grunt_type: string
template: string
distance: number
description: string
real_grunt_id?: number
}

export interface PoraclePokemon {
uid: number
id: string
ping: string
clean: boolean
pokemon_id: number
distance: number
min_iv: number
max_iv: number
min_cp: number
max_cp: number
min_level: number
max_level: number
atk: number
def: number
sta: number
template: string
min_weight: number
max_weight: number
form: number
max_atk: number
max_def: number
max_sta: number
gender: number
profile_no: number
min_time: number
rarity: number
max_rarity: number
size: number
max_size: number
pvp_ranking_worst: number
pvp_ranking_best: number
pvp_ranking_min_cp: number
pvp_ranking_league: number
pvp_ranking_cap: number
description: string
}

export interface PoracleLure {
uid: number
id: string
profile_no: number
ping: string
clean: boolean
lure_id: number
template: string
distance: number
description: string
}

export interface PoracleQuest {
uid: number
id: string
profile_no: number
ping: string
clean: boolean
template: string
distance: number
amount: number
form: number
reward: number
reward_type: number
shiny: boolean
description: string
}

export interface PoracleNest {
uid: number
id: string
profile_no: number
ping: string
clean: boolean
template: string
distance: number
min_spawn_avg: number
pokemon_id: number
form: number
description?: string
}

export interface PoracleWeather {
uid: number
id: string
profile_no: number
ping: string
clean: boolean
template: string
cell: number
condition: number
description: string
}
} & Record<string, unknown>

export type PoracleGym = PoracleRule
export type PoracleRaid = PoracleRule
export type PoracleEgg = PoracleRule
export type PoracleInvasion = PoracleRule
export type PoracleIncident = PoracleRule
export type PoraclePokemon = PoracleRule
export type PoracleLure = PoracleRule
export type PoracleQuest = PoracleRule
export type PoracleNest = PoracleRule

export interface Poracle {
status: string
message: string
category: string
human: PoracleHuman
gym: PoracleGym[]
egg: PoracleEgg[]
raid: PoracleRaid[]
pokemon: PoraclePokemon[]
invasion: PoracleInvasion[]
lure: PoracleLure[]
quest: PoracleQuest[]
profile: PoracleProfile[]
nest: PoracleNest[]
weather: PoracleWeather[]
pokemon: PoracleRule[]
raid: PoracleRule[]
egg: PoracleRule[]
quest: PoracleRule[]
invasion: PoracleRule[]
incident: PoracleRule[]
lure: PoracleRule[]
nest: PoracleRule[]
gym: PoracleRule[]
}

export interface PoracleHumanArea {
Expand All @@ -234,6 +98,7 @@ export type PoracleCategory =
| 'profiles'
| 'egg'
| 'invasion'
| 'incident'
| 'lure'
| 'nest'
| 'pokemon'
Expand Down Expand Up @@ -319,7 +184,7 @@ interface APIReturnType {
lure: PoracleLure[]
quest: PoracleQuest[]
nest: PoracleNest[]
weather: PoracleWeather[]
incident: PoracleIncident[]
profile: PoracleProfile[]
profiles: PoracleProfile[]
gym: PoracleGym[]
Expand Down
47 changes: 3 additions & 44 deletions server/src/graphql/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,27 +607,6 @@ const resolvers = {
category,
status,
)
if (category === 'pokemon' && result.pokemon) {
result.pokemon = result.pokemon.map((x) => ({
...x,
allForms: !x.form,
pvpEntry: !!x.pvp_ranking_league,
xs: x.max_weight !== 9000000,
xl: x.min_weight !== 0,
}))
}
if (category === 'invasion' && result.invasion) {
result.invasion = result.invasion.map((x) => ({
...x,
real_grunt_id: PoracleAPI.getRealGruntId(x, Event.invasions),
}))
}
if (category === 'raid' && result.raid) {
result.raid = result.raid.map((x) => ({
...x,
allMoves: x.move === 9000,
}))
}
return result
}
return {}
Expand All @@ -642,13 +621,14 @@ const resolvers = {
},
webhookCategories: async (_, __, { req, perms, Event }) => {
if (req.user?.id && perms.webhooks.includes(req.user?.selectedWebhook)) {
const human = await Event.webhookObj[req.user?.selectedWebhook].api(
// api() wraps the human as { human }; on a failed read it has none.
const { human } = await Event.webhookObj[req.user?.selectedWebhook].api(
PoracleAPI.getWebhookId(req.user),
'oneHuman',
'GET',
)
return Event.webhookObj[req.user?.selectedWebhook].getAllowedCategories(
human.blocked_alerts,
human?.blocked_alerts,
)
}
return []
Expand Down Expand Up @@ -772,27 +752,6 @@ const resolvers = {
status,
data,
)
if (category === 'pokemon' && result.pokemon) {
result.pokemon = result.pokemon.map((x) => ({
...x,
allForms: !x.form,
pvpEntry: !!x.pvp_ranking_league,
xs: x.max_weight !== 9000000,
xl: x.min_weight !== 0,
}))
}
if (category === 'invasion' && result.invasion) {
result.invasion = result.invasion.map((x) => ({
...x,
real_grunt_id: PoracleAPI.getRealGruntId(x, Event.invasions),
}))
}
if (category === 'raid' && result.raid) {
result.raid = result.raid.map((x) => ({
...x,
allMoves: x.move === 9000,
}))
}
return result
}
return {}
Expand Down
Loading
Loading