From a0c6cdc69f80654b84bab4f0c7271deb61ec1203 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 22 Apr 2023 17:34:19 +0200 Subject: [PATCH 01/72] Add basic TS setup --- .gitignore | 1 + tsconfig.json | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index 399a618..0eda85a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +built/ # Logs npm-debug.log* diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..3930163 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "outDir": "./built", + "allowJs": true, + "target": "es6" + }, + "include": ["./src/**/*"] + } \ No newline at end of file From f4afd52e56135990d31d3da6659e019a14925d00 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 22 Apr 2023 17:34:44 +0200 Subject: [PATCH 02/72] Add node types as dev dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 37ba402..f1e4e2a 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "querystringify": "^2.0.0" }, "devDependencies": { + "@types/node": "^18.15.13", "babel-plugin-rewire": "^1.2.0", "jest": "^23.6.0", "mockdate": "^2.0.2", From b649f206b718d1d387e61f6f5075e0e5f848511e Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 22 Apr 2023 20:37:42 +0200 Subject: [PATCH 03/72] Start migration on endpoints and smaller files --- src/{endpoint.js => endpoint.ts} | 128 +++++++++++++-------- src/endpoints/{wvw.js => wvw.ts} | 33 ++++-- src/{flow.js => flow.ts} | 5 +- src/{hash.js => hash.ts} | 6 +- src/helpers/{resetTime.js => resetTime.ts} | 20 +--- 5 files changed, 111 insertions(+), 81 deletions(-) rename src/{endpoint.js => endpoint.ts} (82%) rename src/endpoints/{wvw.js => wvw.ts} (83%) rename src/{flow.js => flow.ts} (80%) rename src/{hash.js => hash.ts} (65%) rename src/helpers/{resetTime.js => resetTime.ts} (79%) diff --git a/src/endpoint.js b/src/endpoint.ts similarity index 82% rename from src/endpoint.js rename to src/endpoint.ts index 27cfbf3..6a0fea6 100644 --- a/src/endpoint.js +++ b/src/endpoint.ts @@ -3,79 +3,107 @@ const unique = require('array-unique') const chunk = require('chunk') const hashString = require('./hash') -const clone = (x) => JSON.parse(JSON.stringify(x)) +// FIXME: replace with structuredClone? +const clone = (x: T): T => JSON.parse(JSON.stringify(x)) + + +type Language = 'en' | 'de' | 'es' | 'fr' +type Url = string + +interface Headers { + headers: { + get: (prop: string) => T + }, + json: Function +} + +interface IDable { + id: number +} + +export class AbstractEndpoint { + public client + protected schemaVersion: string + protected lang: Language + protected apiKey + protected fetch + protected caches + protected debug + protected baseUrl = 'https://api.guildwars2.com' + protected isPaginated = false + protected maxPageSize = 200 + protected isBulk = false + protected supportsBulkAll = true + protected isLocalized = false + protected isAuthenticated = false + protected isOptionallyAuthenticated = false + protected credentials = false + private _skipCache = false + + protected url: string + protected cacheTime: number -module.exports = class AbstractEndpoint { constructor (parent) { this.client = parent.client - this.schemaVersion = parent.schemaVersion || '2019-03-20T00:00:00.000Z' + this.schemaVersion = parent.schemaVersion ?? '2019-03-20T00:00:00.000Z' this.lang = parent.lang this.apiKey = parent.apiKey this.fetch = parent.fetch this.caches = parent.caches this.debug = parent.debug - - this.baseUrl = 'https://api.guildwars2.com' - this.isPaginated = false - this.maxPageSize = 200 - this.isBulk = false - this.supportsBulkAll = true - this.isLocalized = false - this.isAuthenticated = false - this.isOptionallyAuthenticated = false - this.credentials = false - - this._skipCache = false } // Set the schema version - schema (schema) { + // FIXME: Type + public schema (schema): AbstractEndpoint { this.schemaVersion = schema this.debugMessage(`set the schema to ${schema}`) return this } // Check if the schema version includes a specific version - _schemaIncludes (date) { + private _schemaIncludes (date): boolean { return this.schemaVersion >= date } // Set the language for locale-aware endpoints - language (lang) { + public language (lang: Language): AbstractEndpoint { this.lang = lang this.debugMessage(`set the language to ${lang}`) return this } // Set the api key for authenticated endpoints - authenticate (apiKey) { + // FIXME: type + public authenticate (apiKey): AbstractEndpoint { this.apiKey = apiKey this.debugMessage(`set the api key to ${apiKey}`) return this } // Set the debugging flag - debugging (flag) { + // FIXME: enum + public debugging (flag): AbstractEndpoint { this.debug = flag return this } // Print out a debug message if debugging is enabled - debugMessage (string) { + public debugMessage (string: string) { if (this.debug) { console.log(`[gw2api-client] ${string}`) } } // Skip caching and get the live data - live () { + public live (): AbstractEndpoint { this._skipCache = true this.debugMessage(`skipping cache`) return this } // Get all ids - ids () { + public async ids (): Promise { this.debugMessage(`ids(${this.url}) called`) if (!this.isBulk) { @@ -110,13 +138,15 @@ module.exports = class AbstractEndpoint { } // Get all ids from the live API - _ids () { + private async _ids (): Promise { this.debugMessage(`ids(${this.url}) requesting from api`) return this._request(this.url) } // Get a single entry by id - get (id, url = false) { + public async get (id: string, url: true): Promise; + public async get (id: number, url: false): Promise; + public async get (id: number | string, url: boolean = false): Promise { this.debugMessage(`get(${this.url}) called`) if (!id && this.isBulk && !url) { @@ -151,7 +181,7 @@ module.exports = class AbstractEndpoint { } // Get a single entry by id from the live API - _get (id, url) { + private async _get (id: number | string, url: boolean): Promise { this.debugMessage(`get(${this.url}) requesting from api`) // Request the single id if the endpoint a bulk endpoint @@ -169,7 +199,7 @@ module.exports = class AbstractEndpoint { } // Get multiple entries by ids - many (ids) { + public async many (ids: number[]): Promise { this.debugMessage(`many(${this.url}) called (${ids.length} ids)`) if (!this.isBulk) { @@ -201,7 +231,7 @@ module.exports = class AbstractEndpoint { this.debugMessage(`many(${this.url}) resolving partially from cache (${cached.length} ids)`) const missingIds = getMissingIds(ids, cached) - return this._many(missingIds, cached.length > 0).then(content => { + return this._many(missingIds, cached.length > 0).then(content => { const cacheContent = content.map(value => [this._cacheHash(value.id), value]) this._cacheSetMany(cacheContent) @@ -230,7 +260,7 @@ module.exports = class AbstractEndpoint { } // Get multiple entries by ids from the live API - _many (ids, partialRequest = false) { + private async _many (ids, partialRequest = false): Promise { this.debugMessage(`many(${this.url}) requesting from api (${ids.length} ids)`) // Chunk the requests to the max page size @@ -250,13 +280,13 @@ module.exports = class AbstractEndpoint { } // Work on all requests in parallel and then flatten the responses into one - return this._requestMany(requests) + return this._requestMany(requests) .then(responses => responses.reduce((x, y) => x.concat(y), [])) .catch(handleMissingIds) } // Get a single page - page (page, size = this.maxPageSize) { + public page (page: number, size = this.maxPageSize) { this.debugMessage(`page(${this.url}) called`) if (!this.isBulk && !this.isPaginated) { @@ -284,7 +314,7 @@ module.exports = class AbstractEndpoint { return cached } - return this._page(page, size).then(content => { + return this._page(page, size).then(content => { let cacheContent = [[hash, content]] if (this.isBulk) { @@ -305,13 +335,13 @@ module.exports = class AbstractEndpoint { } // Get a single page from the live API - _page (page, size) { + private async _page (page: number, size: number): Promise { this.debugMessage(`page(${this.url}) requesting from api`) return this._request(`${this.url}?page=${page}&page_size=${size}`) } // Get all entries - all () { + public async all (): Promise { this.debugMessage(`all(${this.url}) called`) if (!this.isBulk && !this.isPaginated) { @@ -320,7 +350,7 @@ module.exports = class AbstractEndpoint { // There is no cache time set, so always use the live data if (!this.cacheTime) { - return this._all() + return this._all() } // Get as much as possible out of the cache @@ -331,7 +361,7 @@ module.exports = class AbstractEndpoint { return cached } - return this._all().then(content => { + return this._all().then(content => { let cacheContent = [[hash, content]] if (this.isBulk) { @@ -352,7 +382,7 @@ module.exports = class AbstractEndpoint { } // Get all entries from the live API - _all () { + private _all (): Promise { this.debugMessage(`all(${this.url}) requesting from api`) // Use bulk expansion if the endpoint supports the "all" keyword @@ -362,10 +392,11 @@ module.exports = class AbstractEndpoint { // Get everything via all pages instead let totalEntries - return this._request(`${this.url}?page=0&page_size=${this.maxPageSize}`, 'response') + return this._request(`${this.url}?page=0&page_size=${this.maxPageSize}`, 'response') .then(firstPage => { + // Get the total number of entries off the first page's headers - totalEntries = firstPage.headers.get('X-Result-Total') + totalEntries = firstPage.headers.get('X-Result-Total') return firstPage.json() }) .then(result => { @@ -380,7 +411,7 @@ module.exports = class AbstractEndpoint { requests.push(`${this.url}?page=${page}&page_size=${this.maxPageSize}`) } - return this._requestMany(requests).then(responses => { + return this._requestMany(requests).then(responses => { responses = responses.reduce((x, y) => x.concat(y), []) return result.concat(responses) }) @@ -460,7 +491,8 @@ module.exports = class AbstractEndpoint { } // Execute a single request - _request (url, type = 'json') { + // FIXME: not sure if Headers is best placed here + private async _request (url, type = 'json'): Promise { url = this._buildUrl(url) /* istanbul ignore next */ @@ -470,7 +502,7 @@ module.exports = class AbstractEndpoint { } // Execute multiple requests in parallel - _requestMany (urls, type = 'json') { + private async _requestMany (urls, type = 'json'): Promise { urls = urls.map(url => this._buildUrl(url)) /* istanbul ignore next */ @@ -480,13 +512,13 @@ module.exports = class AbstractEndpoint { } // Build the headers for localization and authentication - _buildUrl (url) { + private _buildUrl (url: string): string { // Add the base url url = this.baseUrl + url // Parse a possibly existing query - const parsedUrl = url.split('?') - let parsedQuery = qs.parse(parsedUrl[1] || '') + const [base, urlParameters] = url.split('?') + const parsedQuery = qs.parse(urlParameters ?? '') let query = {} @@ -509,11 +541,11 @@ module.exports = class AbstractEndpoint { // Build the url with the finished query query = qs.stringify(query, true).replace(/%2C/g, ',') - return parsedUrl[0] + query + return base + query } // Guarantee the element order of bulk results - _sortByIdList (entries, ids) { + private _sortByIdList (entries: IDable[], ids: number[]): IDable[] { // Hash map of the indexes for better time complexity on big arrays let indexMap = {} ids.map((x, i) => { @@ -525,7 +557,7 @@ module.exports = class AbstractEndpoint { return entries } - _usesApiKey () { + private _usesApiKey (): boolean { return this.isAuthenticated && (!this.isOptionallyAuthenticated || this.apiKey) } } diff --git a/src/endpoints/wvw.js b/src/endpoints/wvw.ts similarity index 83% rename from src/endpoints/wvw.js rename to src/endpoints/wvw.ts index a21d5f8..3ed7c72 100644 --- a/src/endpoints/wvw.js +++ b/src/endpoints/wvw.ts @@ -1,23 +1,23 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class WvwEndpoint extends AbstractEndpoint { - abilities () { +export class WvwEndpoint extends AbstractEndpoint { + public abilities (): AbilitiesEndpoint { return new AbilitiesEndpoint(this) } - matches () { + public matches (): MatchesEndpoint { return new MatchesEndpoint(this) } - objectives () { + public objectives (): ObjectivesEndpoint { return new ObjectivesEndpoint(this) } - upgrades () { + public upgrades (): UpgradesEndpoint { return new UpgradesEndpoint(this) } - ranks () { + public ranks (): RanksEndpoint { return new RanksEndpoint(this) } } @@ -33,6 +33,8 @@ class AbilitiesEndpoint extends AbstractEndpoint { } } +interface World {} + class MatchesEndpoint extends AbstractEndpoint { constructor (client) { super(client) @@ -42,8 +44,8 @@ class MatchesEndpoint extends AbstractEndpoint { this.cacheTime = 30 } - world (worldId) { - return super.get(`?world=${worldId}`, true) + world (worldId: number): World { + return super.get(`?world=${worldId}`, true) } overview () { @@ -60,6 +62,9 @@ class MatchesEndpoint extends AbstractEndpoint { } class TeamsEndpoint extends AbstractEndpoint { + private team + private id + constructor (client, id, team) { super(client) this.team = team @@ -67,12 +72,14 @@ class TeamsEndpoint extends AbstractEndpoint { this.url = `/v2/wvw/matches/stats/${id}/teams` } - top (which) { + public top (which): TopStatsEndpoint { return new TopStatsEndpoint(this, this.id, this.team, which) } } class TopStatsEndpoint extends AbstractEndpoint { + private which + constructor (client, id, team, which) { super(client) this.which = which @@ -89,8 +96,8 @@ class MatchesOverviewEndpoint extends AbstractEndpoint { this.cacheTime = 30 } - world (worldId) { - return super.get(`?world=${worldId}`, true) + public world (worldId): Promise { + return super.get(`?world=${worldId}`, true) } } @@ -109,6 +116,8 @@ class MatchesScoresEndpoint extends AbstractEndpoint { } class MatchesStatsEndpoint extends AbstractEndpoint { + private id + constructor (client, id) { super(client) this.id = id diff --git a/src/flow.js b/src/flow.ts similarity index 80% rename from src/flow.js rename to src/flow.ts index ef51076..e086399 100644 --- a/src/flow.js +++ b/src/flow.ts @@ -1,4 +1,5 @@ -async function parallel (promises) { +// FIXME: a bit handywavey... +export async function parallel (promises: Function): Promise { const results = await Promise.all( Object.values(promises).map(func => func()) ) @@ -15,5 +16,3 @@ async function parallel (promises) { return object }, {}) } - -module.exports = { parallel } diff --git a/src/hash.js b/src/hash.ts similarity index 65% rename from src/hash.js rename to src/hash.ts index 84b8050..c309715 100644 --- a/src/hash.js +++ b/src/hash.ts @@ -1,13 +1,11 @@ const emotionHash = require('@emotion/hash/dist/hash.browser.cjs.js').default -let cache = {} +const cache: {[key: string]: string} = {} -function hash (string) { +export function hash (string: string): string { if (!cache[string]) { cache[string] = emotionHash(string) } return cache[string] } - -module.exports = hash diff --git a/src/helpers/resetTime.js b/src/helpers/resetTime.ts similarity index 79% rename from src/helpers/resetTime.js rename to src/helpers/resetTime.ts index 59d50ee..1f0dbcc 100644 --- a/src/helpers/resetTime.js +++ b/src/helpers/resetTime.ts @@ -1,21 +1,21 @@ const DAY_MS = 24 * 60 * 60 * 1000 -function getDateAtTime (date, time) { +export function getDateAtTime (date: Date, time: string): Date { return new Date(date.toISOString().replace(/T.*Z/, `T${time}.000Z`)) } -function getDailyReset (date) { +export function getDailyReset (date: Date): Date { date = date ? new Date(date) : new Date() date = new Date(date.getTime() + DAY_MS) return getDateAtTime(date, '00:00:00') } -function getLastDailyReset (date) { +export function getLastDailyReset (date: Date): Date { return new Date(getDailyReset(date).getTime() - DAY_MS) } -function getWeeklyReset (date) { +export function getWeeklyReset (date: Date): Date { date = date ? new Date(date) : new Date() const weekday = date.getUTCDay() @@ -48,14 +48,6 @@ function getWeeklyReset (date) { return getDateAtTime(date, '07:30:00') } -function getLastWeeklyReset (date) { +export function getLastWeeklyReset (date: Date): Date { return new Date(getWeeklyReset(date).getTime() - 7 * DAY_MS) -} - -module.exports = { - getDateAtTime, - getDailyReset, - getLastDailyReset, - getWeeklyReset, - getLastWeeklyReset -} +} \ No newline at end of file From 4eeef21e242514c9e113531a3004e8380a4243ea Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 22 Apr 2023 21:18:01 +0200 Subject: [PATCH 04/72] Add type safety for worlds, teams, matchups --- src/endpoint.ts | 2 +- src/endpoints/wvw.ts | 99 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 86 insertions(+), 15 deletions(-) diff --git a/src/endpoint.ts b/src/endpoint.ts index 6a0fea6..901b149 100644 --- a/src/endpoint.ts +++ b/src/endpoint.ts @@ -29,7 +29,7 @@ export class AbstractEndpoint { protected fetch protected caches protected debug - protected baseUrl = 'https://api.guildwars2.com' + protected baseUrl: Url = 'https://api.guildwars2.com' protected isPaginated = false protected maxPageSize = 200 protected isBulk = false diff --git a/src/endpoints/wvw.ts b/src/endpoints/wvw.ts index 3ed7c72..2781421 100644 --- a/src/endpoints/wvw.ts +++ b/src/endpoints/wvw.ts @@ -1,5 +1,76 @@ import { AbstractEndpoint } from '../endpoint' +type Team = 'red' | 'blue' | 'green' +type Top = 'kills' | 'kdr' + +namespace NA { + export type MatchupID = '1-1' | '1-2' | '1-3' | '1-4' + export enum WorldID { + AnvilRock = 1001, + BorlisPass = 1002, + YaksBend = 1003, + HengeOfDenravi = 1004, + Maguuma = 1005, + SorrowsFurnace = 1006, + GateOfMadness = 1007, + JadeQuarry = 1008, + FortAspendWood = 1009, + EhmryBay = 1010, + StormbluffIsle = 1011, + Darkhaven = 1012, + SanctumOfRall = 1013, + CrystalDesert = 1014, + IsleOfJanthir = 1015, + SeaOfSorrows = 1016, + TarnishedCoast = 1017, + NorthernShiverpeaks = 1018, + Blackgate = 1019, + FergusonsCrossing = 1020, + Dragonbrand = 1021, + Kaineng = 1022, + DevonasRest = 1023, + EredonsTerrace = 1024 + } +} + +namespace EU { + export type MatchupID = '2-1' | '2-2' | '2-3' | '2-4' + export enum WorldID { + FissureOfWoe = 2001, + Desolation = 2002, + Gandara = 2003, + Blacktide = 2004, + RingOfFire = 2005, + Underworld = 2006, + FarShiverpeaks = 2007, + WhitesideRidge = 2008, + RuinsOfSurmia = 2009, + SeafarersRest = 2010, + Vabbi = 2011, + PikenSquare = 2012, + AuroraGlade = 2013, + GunnarsHold = 2014, + JadeSea = 2101, + FortRanik = 2102, + AuguryRock = 2103, + VizunahSquare = 2104, + Arborstone = 2105, + Kodash = 2201, + Riverside = 2202, + ElonaReach = 2203, + AbaddonsMouth = 2204, + DrakkarLake = 2205, + MillersSound = 2206, + Dzagonur = 2207, + BaruchBay = 2301 + } +} + +type MatchupID = NA.MatchupID | EU.MatchupID +type WorldID = NA.WorldID | EU.WorldID + + + export class WvwEndpoint extends AbstractEndpoint { public abilities (): AbilitiesEndpoint { return new AbilitiesEndpoint(this) @@ -44,7 +115,7 @@ class MatchesEndpoint extends AbstractEndpoint { this.cacheTime = 30 } - world (worldId: number): World { + world (worldId: WorldID): World { return super.get(`?world=${worldId}`, true) } @@ -56,31 +127,31 @@ class MatchesEndpoint extends AbstractEndpoint { return new MatchesScoresEndpoint(this) } - stats (id) { + stats (id: MatchupID) { return new MatchesStatsEndpoint(this, id) } } class TeamsEndpoint extends AbstractEndpoint { - private team - private id + private team: Team + private id: MatchupID - constructor (client, id, team) { + constructor (client, id: MatchupID, team: Team) { super(client) this.team = team this.id = id this.url = `/v2/wvw/matches/stats/${id}/teams` } - public top (which): TopStatsEndpoint { + public top (which: Top): TopStatsEndpoint { return new TopStatsEndpoint(this, this.id, this.team, which) } } class TopStatsEndpoint extends AbstractEndpoint { - private which + private which: Top - constructor (client, id, team, which) { + constructor (client, id: MatchupID, team: Team, which: Top) { super(client) this.which = which this.url = `/v2/wvw/matches/stats/${id}/teams/${team}/top/${which}` @@ -96,7 +167,7 @@ class MatchesOverviewEndpoint extends AbstractEndpoint { this.cacheTime = 30 } - public world (worldId): Promise { + public world (worldId: WorldID): Promise { return super.get(`?world=${worldId}`, true) } } @@ -110,15 +181,15 @@ class MatchesScoresEndpoint extends AbstractEndpoint { this.cacheTime = 30 } - world (worldId) { + public world (worldId: WorldID) { return super.get(`?world=${worldId}`, true) } } class MatchesStatsEndpoint extends AbstractEndpoint { - private id + private id: MatchupID - constructor (client, id) { + constructor (client, id: MatchupID) { super(client) this.id = id this.url = '/v2/wvw/matches/stats' @@ -127,11 +198,11 @@ class MatchesStatsEndpoint extends AbstractEndpoint { this.cacheTime = 30 } - world (worldId) { + public world (worldId: WorldID) { return super.get(`?world=${worldId}`, true) } - teams (team) { + public teams (team: Team) { return new TeamsEndpoint(this, this.id, team) } } From e68e24fbc47d454f66e44fbb2f0f46f2f3eaa185 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 22 Apr 2023 21:19:25 +0200 Subject: [PATCH 05/72] Convert world endpoint --- src/endpoints/{worlds.js => worlds.ts} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/endpoints/{worlds.js => worlds.ts} (62%) diff --git a/src/endpoints/worlds.js b/src/endpoints/worlds.ts similarity index 62% rename from src/endpoints/worlds.js rename to src/endpoints/worlds.ts index 5ac78e8..137d4c7 100644 --- a/src/endpoints/worlds.js +++ b/src/endpoints/worlds.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class WorldsEndpoint extends AbstractEndpoint { +export class WorldsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/worlds' From bb3178fa940aed4dcd02ae59b417b4838662dd6f Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 22 Apr 2023 22:00:22 +0200 Subject: [PATCH 06/72] Convert all js endpoints to ts --- .../{account-blob.js => account-blob.ts} | 0 src/endpoints/{account.js => account.ts} | 6 +-- .../{achievements.js => achievements.ts} | 4 +- src/endpoints/{backstory.js => backstory.ts} | 4 +- src/endpoints/{build.js => build.ts} | 4 +- src/endpoints/{cats.js => cats.ts} | 4 +- .../{characters.js => characters.ts} | 0 src/endpoints/{colors.js => colors.ts} | 4 +- src/endpoints/{commerce.js => commerce.ts} | 18 ++++----- .../{continents.js => continents.ts} | 8 ++-- .../{currencies.js => currencies.ts} | 4 +- .../{dailycrafting.js => dailycrafting.ts} | 4 +- src/endpoints/{dungeons.js => dungeons.ts} | 4 +- src/endpoints/{emblem.js => emblem.ts} | 8 ++-- src/endpoints/{events.js => events.ts} | 12 +++--- src/endpoints/{files.js => files.ts} | 4 +- src/endpoints/{finishers.js => finishers.ts} | 4 +- src/endpoints/{gliders.js => gliders.ts} | 4 +- src/endpoints/{guild.js => guild.ts} | 40 +++++++++++-------- src/endpoints/{home.js => home.ts} | 8 ++-- src/endpoints/{index.js => index.ts} | 0 src/endpoints/{items.js => items.ts} | 4 +- src/endpoints/{itemstats.js => itemstats.ts} | 4 +- ...{legendaryarmory.js => legendaryarmory.ts} | 4 +- src/endpoints/{legends.js => legends.ts} | 4 +- .../{mailcarriers.js => mailcarriers.ts} | 4 +- src/endpoints/{mapchests.js => mapchests.ts} | 4 +- src/endpoints/{maps.js => maps.ts} | 4 +- src/endpoints/{masteries.js => masteries.ts} | 4 +- src/endpoints/{materials.js => materials.ts} | 4 +- src/endpoints/{minis.js => minis.ts} | 4 +- src/endpoints/{mounts.js => mounts.ts} | 8 ++-- src/endpoints/{nodes.js => nodes.ts} | 4 +- src/endpoints/{novelties.js => novelties.ts} | 4 +- src/endpoints/{outfits.js => outfits.ts} | 4 +- src/endpoints/{pets.js => pets.ts} | 4 +- .../{professions.js => professions.ts} | 4 +- src/endpoints/{pvp.js => pvp.ts} | 27 +++++++++---- src/endpoints/{quaggans.js => quaggans.ts} | 4 +- src/endpoints/{quests.js => quests.ts} | 4 +- src/endpoints/{races.js => races.ts} | 4 +- src/endpoints/{raids.js => raids.ts} | 4 +- src/endpoints/{recipes.js => recipes.ts} | 12 +++--- src/endpoints/{skills.js => skills.ts} | 5 +-- src/endpoints/{skins.js => skins.ts} | 4 +- ...{specializations.js => specializations.ts} | 4 +- src/endpoints/{stories.js => stories.ts} | 6 +-- src/endpoints/{titles.js => titles.ts} | 4 +- src/endpoints/{tokeninfo.js => tokeninfo.ts} | 4 +- src/endpoints/{traits.js => traits.ts} | 4 +- .../{worldbosses.js => worldbosses.ts} | 4 +- src/types.ts | 1 + 52 files changed, 162 insertions(+), 141 deletions(-) rename src/endpoints/{account-blob.js => account-blob.ts} (100%) rename src/endpoints/{account.js => account.ts} (98%) rename src/endpoints/{achievements.js => achievements.ts} (91%) rename src/endpoints/{backstory.js => backstory.ts} (85%) rename src/endpoints/{build.js => build.ts} (59%) rename src/endpoints/{cats.js => cats.ts} (59%) rename src/endpoints/{characters.js => characters.ts} (100%) rename src/endpoints/{colors.js => colors.ts} (62%) rename src/endpoints/{commerce.js => commerce.ts} (87%) rename src/endpoints/{continents.js => continents.ts} (73%) rename src/endpoints/{currencies.js => currencies.ts} (62%) rename src/endpoints/{dailycrafting.js => dailycrafting.ts} (62%) rename src/endpoints/{dungeons.js => dungeons.ts} (58%) rename src/endpoints/{emblem.js => emblem.ts} (64%) rename src/endpoints/{events.js => events.ts} (68%) rename src/endpoints/{files.js => files.ts} (59%) rename src/endpoints/{finishers.js => finishers.ts} (62%) rename src/endpoints/{gliders.js => gliders.ts} (62%) rename src/endpoints/{guild.js => guild.ts} (79%) rename src/endpoints/{home.js => home.ts} (75%) rename src/endpoints/{index.js => index.ts} (100%) rename src/endpoints/{items.js => items.ts} (66%) rename src/endpoints/{itemstats.js => itemstats.ts} (62%) rename src/endpoints/{legendaryarmory.js => legendaryarmory.ts} (58%) rename src/endpoints/{legends.js => legends.ts} (58%) rename src/endpoints/{mailcarriers.js => mailcarriers.ts} (62%) rename src/endpoints/{mapchests.js => mapchests.ts} (62%) rename src/endpoints/{maps.js => maps.ts} (63%) rename src/endpoints/{masteries.js => masteries.ts} (62%) rename src/endpoints/{materials.js => materials.ts} (62%) rename src/endpoints/{minis.js => minis.ts} (62%) rename src/endpoints/{mounts.js => mounts.ts} (76%) rename src/endpoints/{nodes.js => nodes.ts} (59%) rename src/endpoints/{novelties.js => novelties.ts} (62%) rename src/endpoints/{outfits.js => outfits.ts} (62%) rename src/endpoints/{pets.js => pets.ts} (63%) rename src/endpoints/{professions.js => professions.ts} (62%) rename src/endpoints/{pvp.js => pvp.ts} (85%) rename src/endpoints/{quaggans.js => quaggans.ts} (58%) rename src/endpoints/{quests.js => quests.ts} (62%) rename src/endpoints/{races.js => races.ts} (62%) rename src/endpoints/{raids.js => raids.ts} (59%) rename src/endpoints/{recipes.js => recipes.ts} (68%) rename src/endpoints/{skills.js => skills.ts} (62%) rename src/endpoints/{skins.js => skins.ts} (66%) rename src/endpoints/{specializations.js => specializations.ts} (62%) rename src/endpoints/{stories.js => stories.ts} (77%) rename src/endpoints/{titles.js => titles.ts} (62%) rename src/endpoints/{tokeninfo.js => tokeninfo.ts} (54%) rename src/endpoints/{traits.js => traits.ts} (62%) rename src/endpoints/{worldbosses.js => worldbosses.ts} (62%) create mode 100644 src/types.ts diff --git a/src/endpoints/account-blob.js b/src/endpoints/account-blob.ts similarity index 100% rename from src/endpoints/account-blob.js rename to src/endpoints/account-blob.ts diff --git a/src/endpoints/account.js b/src/endpoints/account.ts similarity index 98% rename from src/endpoints/account.js rename to src/endpoints/account.ts index dae73f6..0306f89 100644 --- a/src/endpoints/account.js +++ b/src/endpoints/account.ts @@ -1,11 +1,11 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' const CharactersEndpoint = require('./characters') const PvpEndpoint = require('./pvp') const CommerceEndpoint = require('./commerce') const accountBlob = require('./account-blob.js') const resetTime = require('../helpers/resetTime') -class AccountEndpoint extends AbstractEndpoint { +export class AccountEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/account' @@ -457,5 +457,3 @@ async function isStaleWeeklyData (endpointInstance) { const account = await new AccountEndpoint(endpointInstance).schema('2019-03-26').get() return new Date(account.last_modified) < resetTime.getLastWeeklyReset() } - -module.exports = AccountEndpoint diff --git a/src/endpoints/achievements.js b/src/endpoints/achievements.ts similarity index 91% rename from src/endpoints/achievements.js rename to src/endpoints/achievements.ts index 1d71055..b9e445f 100644 --- a/src/endpoints/achievements.js +++ b/src/endpoints/achievements.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class AchievementsEndpoint extends AbstractEndpoint { +export class AchievementsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements' diff --git a/src/endpoints/backstory.js b/src/endpoints/backstory.ts similarity index 85% rename from src/endpoints/backstory.js rename to src/endpoints/backstory.ts index 53655eb..71889eb 100644 --- a/src/endpoints/backstory.js +++ b/src/endpoints/backstory.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class BackstoryEndpoint extends AbstractEndpoint { +export class BackstoryEndpoint extends AbstractEndpoint { answers () { return new AnswersEndpoint(this) } diff --git a/src/endpoints/build.js b/src/endpoints/build.ts similarity index 59% rename from src/endpoints/build.js rename to src/endpoints/build.ts index baa0430..afc766f 100644 --- a/src/endpoints/build.js +++ b/src/endpoints/build.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class BuildEndpoint extends AbstractEndpoint { +export class BuildEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/build' diff --git a/src/endpoints/cats.js b/src/endpoints/cats.ts similarity index 59% rename from src/endpoints/cats.js rename to src/endpoints/cats.ts index 04d9a76..8dcf63b 100644 --- a/src/endpoints/cats.js +++ b/src/endpoints/cats.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class CatsEndpoint extends AbstractEndpoint { +export class CatsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/cats' diff --git a/src/endpoints/characters.js b/src/endpoints/characters.ts similarity index 100% rename from src/endpoints/characters.js rename to src/endpoints/characters.ts diff --git a/src/endpoints/colors.js b/src/endpoints/colors.ts similarity index 62% rename from src/endpoints/colors.js rename to src/endpoints/colors.ts index 8bb97e6..6a70436 100644 --- a/src/endpoints/colors.js +++ b/src/endpoints/colors.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class ColorsEndpoint extends AbstractEndpoint { +export class ColorsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/colors' diff --git a/src/endpoints/commerce.js b/src/endpoints/commerce.ts similarity index 87% rename from src/endpoints/commerce.js rename to src/endpoints/commerce.ts index 248ac47..a444c79 100644 --- a/src/endpoints/commerce.js +++ b/src/endpoints/commerce.ts @@ -1,28 +1,28 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class CommerceEndpoint extends AbstractEndpoint { +export class CommerceEndpoint extends AbstractEndpoint { // Current things to grab in the delivery box - delivery () { + public delivery () { return new DeliveryEndpoint(this) } // Current gem/coin exchange rates - exchange () { + public exchange () { return new ExchangeEndpoint(this) } // Current tradingpost listings - listings () { + public listings () { return new ListingsEndpoint(this) } // Current tradingpost prices - prices () { + public prices () { return new PricesEndpoint(this) } // Current and completed transactions - transactions () { + public transactions () { return { current: () => ({ buys: () => new TransactionsEndpoint(this, 'current', 'buys'), @@ -52,11 +52,11 @@ class ExchangeEndpoint extends AbstractEndpoint { this.cacheTime = 10 * 60 } - gems (quantity) { + gems (quantity: number) { return super.get(`/gems?quantity=${quantity}`, true) } - coins (quantity) { + coins (quantity: number) { return super.get(`/coins?quantity=${quantity}`, true) } } diff --git a/src/endpoints/continents.js b/src/endpoints/continents.ts similarity index 73% rename from src/endpoints/continents.js rename to src/endpoints/continents.ts index b301b3e..6895a4a 100644 --- a/src/endpoints/continents.js +++ b/src/endpoints/continents.ts @@ -1,6 +1,8 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class ContinentsEndpoint extends AbstractEndpoint { +type FloorID = number + +export class ContinentsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/continents' @@ -10,7 +12,7 @@ module.exports = class ContinentsEndpoint extends AbstractEndpoint { this.cacheTime = 24 * 60 * 60 } - floors (id) { + public floors (id: FloorID): FloorsEndpoint { return new FloorsEndpoint(this, id) } } diff --git a/src/endpoints/currencies.js b/src/endpoints/currencies.ts similarity index 62% rename from src/endpoints/currencies.js rename to src/endpoints/currencies.ts index 495d533..fd9218f 100644 --- a/src/endpoints/currencies.js +++ b/src/endpoints/currencies.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class CurrenciesEndpoint extends AbstractEndpoint { +export class CurrenciesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/currencies' diff --git a/src/endpoints/dailycrafting.js b/src/endpoints/dailycrafting.ts similarity index 62% rename from src/endpoints/dailycrafting.js rename to src/endpoints/dailycrafting.ts index b8cfaa2..b78d05c 100644 --- a/src/endpoints/dailycrafting.js +++ b/src/endpoints/dailycrafting.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class DailycraftingEndpoint extends AbstractEndpoint { +export class DailycraftingEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/dailycrafting' diff --git a/src/endpoints/dungeons.js b/src/endpoints/dungeons.ts similarity index 58% rename from src/endpoints/dungeons.js rename to src/endpoints/dungeons.ts index ccfc604..a5379de 100644 --- a/src/endpoints/dungeons.js +++ b/src/endpoints/dungeons.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class DungeonsEndpoint extends AbstractEndpoint { +export class DungeonsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/dungeons' diff --git a/src/endpoints/emblem.js b/src/endpoints/emblem.ts similarity index 64% rename from src/endpoints/emblem.js rename to src/endpoints/emblem.ts index 5d67e77..73792e9 100644 --- a/src/endpoints/emblem.js +++ b/src/endpoints/emblem.ts @@ -1,11 +1,11 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class EmblemEndpoint extends AbstractEndpoint { - backgrounds () { +export class EmblemEndpoint extends AbstractEndpoint { + public backgrounds (): LayersEndpoint { return new LayersEndpoint(this, 'backgrounds') } - foregrounds () { + public foregrounds (): LayersEndpoint { return new LayersEndpoint(this, 'foregrounds') } } diff --git a/src/endpoints/events.js b/src/endpoints/events.ts similarity index 68% rename from src/endpoints/events.js rename to src/endpoints/events.ts index b39231a..1eaf8bc 100644 --- a/src/endpoints/events.js +++ b/src/endpoints/events.ts @@ -1,22 +1,24 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class EventsEndpoint extends AbstractEndpoint { +type EventID = string + +export class EventsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v1/event_details.json' this.cacheTime = 24 * 60 * 60 } - all () { + public all () { return super.get().then(transformV1Format) } - get (id) { + public get (id: EventID) { return super.get(`?event_id=${id}`, true).then(json => transformV1Format(json)[0]) } } -function transformV1Format (json) { +function transformV1Format (json: {events: any[]}): {}[] { let events = json.events let transformed = [] const keys = Object.keys(events) diff --git a/src/endpoints/files.js b/src/endpoints/files.ts similarity index 59% rename from src/endpoints/files.js rename to src/endpoints/files.ts index 565d249..fb78d5e 100644 --- a/src/endpoints/files.js +++ b/src/endpoints/files.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class FilesEndpoint extends AbstractEndpoint { +export class FilesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/files' diff --git a/src/endpoints/finishers.js b/src/endpoints/finishers.ts similarity index 62% rename from src/endpoints/finishers.js rename to src/endpoints/finishers.ts index 7c4b105..fda9d16 100644 --- a/src/endpoints/finishers.js +++ b/src/endpoints/finishers.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class FinishersEndpoint extends AbstractEndpoint { +export class FinishersEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/finishers' diff --git a/src/endpoints/gliders.js b/src/endpoints/gliders.ts similarity index 62% rename from src/endpoints/gliders.js rename to src/endpoints/gliders.ts index fa237ab..6916720 100644 --- a/src/endpoints/gliders.js +++ b/src/endpoints/gliders.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class GlidersEndpoint extends AbstractEndpoint { +export class GlidersEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/gliders' diff --git a/src/endpoints/guild.js b/src/endpoints/guild.ts similarity index 79% rename from src/endpoints/guild.js rename to src/endpoints/guild.ts index 6ffda69..ed387aa 100644 --- a/src/endpoints/guild.js +++ b/src/endpoints/guild.ts @@ -1,7 +1,12 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class GuildEndpoint extends AbstractEndpoint { - constructor (client, id) { +type GuildID = string +type LogID = number + +export class GuildEndpoint extends AbstractEndpoint { + private id: GuildID + + constructor (client, id: GuildID) { super(client) this.id = id this.url = '/v2/guild' @@ -10,19 +15,20 @@ module.exports = class GuildEndpoint extends AbstractEndpoint { this.cacheTime = 60 * 60 } - get (id) { + public get (id: GuildID) { return super.get(`/${id}`, true) } - permissions () { + public permissions (): PermissionsEndpoint { return new PermissionsEndpoint(this) } - search (name) { - return new SearchEndpoint(this, name) + public search (name: string): SearchEndpoint { + // FIXME: bug? Constructor got passed `name` before (which is not received in the constructor) instead of chaining the call + return new SearchEndpoint(this) //, name) } - upgrades () { + public upgrades (): UpgradesEndpoint | AllUpgradesEndpoint { if (this.id === undefined) { return new AllUpgradesEndpoint(this) } @@ -30,31 +36,31 @@ module.exports = class GuildEndpoint extends AbstractEndpoint { return new UpgradesEndpoint(this, this.id) } - log () { + public log (): LogEndpoint { return new LogEndpoint(this, this.id) } - members () { + public members (): MembersEndpoint { return new MembersEndpoint(this, this.id) } - ranks () { + public ranks (): RanksEndpoint { return new RanksEndpoint(this, this.id) } - stash () { + public stash (): StashEndpoint { return new StashEndpoint(this, this.id) } - storage () { + public storage (): StorageEndpoint { return new StorageEndpoint(this, this.id) } - teams () { + public teams (): TeamsEndpoint { return new TeamsEndpoint(this, this.id) } - treasury () { + public treasury (): TreasuryEndpoint { return new TreasuryEndpoint(this, this.id) } } @@ -77,7 +83,7 @@ class SearchEndpoint extends AbstractEndpoint { this.cacheTime = 60 * 60 } - name (name) { + public name (name: string) { return super.get(`?name=${encodeURIComponent(name)}`, true) .then(result => result[0]) } @@ -102,7 +108,7 @@ class LogEndpoint extends AbstractEndpoint { this.cacheTime = 5 * 60 } - since (logId) { + public since (logId: LogID) { return super.get(`?since=${logId}`, true) } } diff --git a/src/endpoints/home.js b/src/endpoints/home.ts similarity index 75% rename from src/endpoints/home.js rename to src/endpoints/home.ts index c4a6faf..4b35671 100644 --- a/src/endpoints/home.js +++ b/src/endpoints/home.ts @@ -1,11 +1,11 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class HomeEndpoint extends AbstractEndpoint { - cats () { +export class HomeEndpoint extends AbstractEndpoint { + public cats (): CatsEndpoint { return new CatsEndpoint(this) } - nodes () { + public nodes (): NodesEndpoint { return new NodesEndpoint(this) } } diff --git a/src/endpoints/index.js b/src/endpoints/index.ts similarity index 100% rename from src/endpoints/index.js rename to src/endpoints/index.ts diff --git a/src/endpoints/items.js b/src/endpoints/items.ts similarity index 66% rename from src/endpoints/items.js rename to src/endpoints/items.ts index 6091d61..e3e8ff1 100644 --- a/src/endpoints/items.js +++ b/src/endpoints/items.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class ItemsEndpoint extends AbstractEndpoint { +export class ItemsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/items' diff --git a/src/endpoints/itemstats.js b/src/endpoints/itemstats.ts similarity index 62% rename from src/endpoints/itemstats.js rename to src/endpoints/itemstats.ts index 798a4ce..1e66bd8 100644 --- a/src/endpoints/itemstats.js +++ b/src/endpoints/itemstats.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class ItemstatsEndpoint extends AbstractEndpoint { +export class ItemstatsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/itemstats' diff --git a/src/endpoints/legendaryarmory.js b/src/endpoints/legendaryarmory.ts similarity index 58% rename from src/endpoints/legendaryarmory.js rename to src/endpoints/legendaryarmory.ts index cafcab5..91021eb 100644 --- a/src/endpoints/legendaryarmory.js +++ b/src/endpoints/legendaryarmory.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class LegendaryarmoryEndpoint extends AbstractEndpoint { +export class LegendaryarmoryEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/legendaryarmory' diff --git a/src/endpoints/legends.js b/src/endpoints/legends.ts similarity index 58% rename from src/endpoints/legends.js rename to src/endpoints/legends.ts index 3bd64df..729568a 100644 --- a/src/endpoints/legends.js +++ b/src/endpoints/legends.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class LegendsEndpoint extends AbstractEndpoint { +export class LegendsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/legends' diff --git a/src/endpoints/mailcarriers.js b/src/endpoints/mailcarriers.ts similarity index 62% rename from src/endpoints/mailcarriers.js rename to src/endpoints/mailcarriers.ts index 26b9e31..27e179c 100644 --- a/src/endpoints/mailcarriers.js +++ b/src/endpoints/mailcarriers.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class MailcarriersEndpoint extends AbstractEndpoint { +export class MailcarriersEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/mailcarriers' diff --git a/src/endpoints/mapchests.js b/src/endpoints/mapchests.ts similarity index 62% rename from src/endpoints/mapchests.js rename to src/endpoints/mapchests.ts index 453eb83..7778344 100644 --- a/src/endpoints/mapchests.js +++ b/src/endpoints/mapchests.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class MapchestsEndpoint extends AbstractEndpoint { +export class MapchestsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/mapchests' diff --git a/src/endpoints/maps.js b/src/endpoints/maps.ts similarity index 63% rename from src/endpoints/maps.js rename to src/endpoints/maps.ts index 4c2c073..59f3327 100644 --- a/src/endpoints/maps.js +++ b/src/endpoints/maps.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class MapsEndpoint extends AbstractEndpoint { +export class MapsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/maps' diff --git a/src/endpoints/masteries.js b/src/endpoints/masteries.ts similarity index 62% rename from src/endpoints/masteries.js rename to src/endpoints/masteries.ts index 2651486..98be0b6 100644 --- a/src/endpoints/masteries.js +++ b/src/endpoints/masteries.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class MasteriesEndpoint extends AbstractEndpoint { +export class MasteriesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/masteries' diff --git a/src/endpoints/materials.js b/src/endpoints/materials.ts similarity index 62% rename from src/endpoints/materials.js rename to src/endpoints/materials.ts index 069b146..5f6cc3c 100644 --- a/src/endpoints/materials.js +++ b/src/endpoints/materials.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class MaterialsEndpoint extends AbstractEndpoint { +export class MaterialsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/materials' diff --git a/src/endpoints/minis.js b/src/endpoints/minis.ts similarity index 62% rename from src/endpoints/minis.js rename to src/endpoints/minis.ts index 9d0f8fa..90ed458 100644 --- a/src/endpoints/minis.js +++ b/src/endpoints/minis.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class MinisEndpoint extends AbstractEndpoint { +export class MinisEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/minis' diff --git a/src/endpoints/mounts.js b/src/endpoints/mounts.ts similarity index 76% rename from src/endpoints/mounts.js rename to src/endpoints/mounts.ts index a5e9dfd..7517995 100644 --- a/src/endpoints/mounts.js +++ b/src/endpoints/mounts.ts @@ -1,11 +1,11 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class MountsEndpoint extends AbstractEndpoint { - skins () { +export class MountsEndpoint extends AbstractEndpoint { + public skins (): SkinsEndpoint { return new SkinsEndpoint(this) } - types () { + public types (): TypesEndpoint { return new TypesEndpoint(this) } } diff --git a/src/endpoints/nodes.js b/src/endpoints/nodes.ts similarity index 59% rename from src/endpoints/nodes.js rename to src/endpoints/nodes.ts index 361fa66..390afb9 100644 --- a/src/endpoints/nodes.js +++ b/src/endpoints/nodes.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class NodesEndpoint extends AbstractEndpoint { +export class NodesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/nodes' diff --git a/src/endpoints/novelties.js b/src/endpoints/novelties.ts similarity index 62% rename from src/endpoints/novelties.js rename to src/endpoints/novelties.ts index 47acce0..b34758b 100644 --- a/src/endpoints/novelties.js +++ b/src/endpoints/novelties.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class NoveltiesEndpoint extends AbstractEndpoint { +export class NoveltiesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/novelties' diff --git a/src/endpoints/outfits.js b/src/endpoints/outfits.ts similarity index 62% rename from src/endpoints/outfits.js rename to src/endpoints/outfits.ts index 673adcb..644a93b 100644 --- a/src/endpoints/outfits.js +++ b/src/endpoints/outfits.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class OutfitsEndpoint extends AbstractEndpoint { +export class OutfitsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/outfits' diff --git a/src/endpoints/pets.js b/src/endpoints/pets.ts similarity index 63% rename from src/endpoints/pets.js rename to src/endpoints/pets.ts index cad51b9..4b12c09 100644 --- a/src/endpoints/pets.js +++ b/src/endpoints/pets.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class PetsEndpoint extends AbstractEndpoint { +export class PetsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/pets' diff --git a/src/endpoints/professions.js b/src/endpoints/professions.ts similarity index 62% rename from src/endpoints/professions.js rename to src/endpoints/professions.ts index 78d0019..9525e49 100644 --- a/src/endpoints/professions.js +++ b/src/endpoints/professions.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class ProfessionsEndpoint extends AbstractEndpoint { +export class ProfessionsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/professions' diff --git a/src/endpoints/pvp.js b/src/endpoints/pvp.ts similarity index 85% rename from src/endpoints/pvp.js rename to src/endpoints/pvp.ts index e397046..2a538ef 100644 --- a/src/endpoints/pvp.js +++ b/src/endpoints/pvp.ts @@ -1,7 +1,14 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class PvpEndpoint extends AbstractEndpoint { - constructor (client, fromAccount) { + +type SeasonID = string +type Region = 'na' | 'eu' +type Board = 'guild' | 'legendary' + +export class PvpEndpoint extends AbstractEndpoint { + private fromAccount: boolean + + constructor (client, fromAccount: boolean) { super(client) this.fromAccount = fromAccount } @@ -93,7 +100,9 @@ class RanksEndpoint extends AbstractEndpoint { } class SeasonsEndpoint extends AbstractEndpoint { - constructor (client, id) { + private id: SeasonID + + constructor (client, id: SeasonID) { super(client) this.id = id this.url = '/v2/pvp/seasons' @@ -109,24 +118,26 @@ class SeasonsEndpoint extends AbstractEndpoint { } class SeasonLeaderboardEndpoint extends AbstractEndpoint { - constructor (client, id) { + private id: SeasonID + + constructor (client, id: SeasonID) { super(client) this.id = id this.url = `/v2/pvp/seasons/${id}/leaderboards` this.cacheTime = 24 * 60 * 60 } - ids () { + public ids () { return super.get('', true) } - board (board, region) { + public board (board, region) { return new SeasonLeaderboardBoardEndpoint(this, this.id, board, region) } } class SeasonLeaderboardBoardEndpoint extends AbstractEndpoint { - constructor (client, id, board, region) { + constructor (client, id: SeasonID, board: Board, region: Region) { super(client) this.url = `/v2/pvp/seasons/${id}/leaderboards/${board}/${region}` this.isPaginated = true diff --git a/src/endpoints/quaggans.js b/src/endpoints/quaggans.ts similarity index 58% rename from src/endpoints/quaggans.js rename to src/endpoints/quaggans.ts index dd7a219..77203de 100644 --- a/src/endpoints/quaggans.js +++ b/src/endpoints/quaggans.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class QuaggansEndpoint extends AbstractEndpoint { +export class QuaggansEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/quaggans' diff --git a/src/endpoints/quests.js b/src/endpoints/quests.ts similarity index 62% rename from src/endpoints/quests.js rename to src/endpoints/quests.ts index 3cd3074..ff0ab9e 100644 --- a/src/endpoints/quests.js +++ b/src/endpoints/quests.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class QuestsEndpoint extends AbstractEndpoint { +export class QuestsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/quests' diff --git a/src/endpoints/races.js b/src/endpoints/races.ts similarity index 62% rename from src/endpoints/races.js rename to src/endpoints/races.ts index 69f5252..d02dbc5 100644 --- a/src/endpoints/races.js +++ b/src/endpoints/races.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class RacesEndpoint extends AbstractEndpoint { +export class RacesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/races' diff --git a/src/endpoints/raids.js b/src/endpoints/raids.ts similarity index 59% rename from src/endpoints/raids.js rename to src/endpoints/raids.ts index 22706ea..946f810 100644 --- a/src/endpoints/raids.js +++ b/src/endpoints/raids.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class RaidsEndpoint extends AbstractEndpoint { +export class RaidsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/raids' diff --git a/src/endpoints/recipes.js b/src/endpoints/recipes.ts similarity index 68% rename from src/endpoints/recipes.js rename to src/endpoints/recipes.ts index aed36da..cacd942 100644 --- a/src/endpoints/recipes.js +++ b/src/endpoints/recipes.ts @@ -1,6 +1,8 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' +import { ItemID } from '../types' -module.exports = class RecipesEndpoint extends AbstractEndpoint { + +export class RecipesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/recipes' @@ -10,7 +12,7 @@ module.exports = class RecipesEndpoint extends AbstractEndpoint { this.cacheTime = 24 * 60 * 60 } - search () { + public search (): SearchEndpoint { return new SearchEndpoint(this) } } @@ -22,11 +24,11 @@ class SearchEndpoint extends AbstractEndpoint { this.cacheTime = 24 * 60 * 60 } - input (id) { + public input (id: ItemID) { return super.get(`?input=${id}`, true) } - output (id) { + public output (id: ItemID) { return super.get(`?output=${id}`, true) } } diff --git a/src/endpoints/skills.js b/src/endpoints/skills.ts similarity index 62% rename from src/endpoints/skills.js rename to src/endpoints/skills.ts index de08f8f..e8131ba 100644 --- a/src/endpoints/skills.js +++ b/src/endpoints/skills.ts @@ -1,6 +1,5 @@ -const AbstractEndpoint = require('../endpoint') - -module.exports = class SkillsEndpoint extends AbstractEndpoint { +import { AbstractEndpoint } from '../endpoint' +export class SkillsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/skills' diff --git a/src/endpoints/skins.js b/src/endpoints/skins.ts similarity index 66% rename from src/endpoints/skins.js rename to src/endpoints/skins.ts index 8fdb33c..0ef3906 100644 --- a/src/endpoints/skins.js +++ b/src/endpoints/skins.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class SkinsEndpoint extends AbstractEndpoint { +export class SkinsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/skins' diff --git a/src/endpoints/specializations.js b/src/endpoints/specializations.ts similarity index 62% rename from src/endpoints/specializations.js rename to src/endpoints/specializations.ts index 2826c07..9450265 100644 --- a/src/endpoints/specializations.js +++ b/src/endpoints/specializations.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class SpecializationsEndpoint extends AbstractEndpoint { +export class SpecializationsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/specializations' diff --git a/src/endpoints/stories.js b/src/endpoints/stories.ts similarity index 77% rename from src/endpoints/stories.js rename to src/endpoints/stories.ts index 746cfbe..71fac11 100644 --- a/src/endpoints/stories.js +++ b/src/endpoints/stories.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class StoriesEndpoint extends AbstractEndpoint { +export class StoriesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/stories' @@ -10,7 +10,7 @@ module.exports = class StoriesEndpoint extends AbstractEndpoint { this.cacheTime = 24 * 60 * 60 } - seasons () { + public seasons (): SeasonsEndpoint { return new SeasonsEndpoint(this) } } diff --git a/src/endpoints/titles.js b/src/endpoints/titles.ts similarity index 62% rename from src/endpoints/titles.js rename to src/endpoints/titles.ts index 6600683..1061b36 100644 --- a/src/endpoints/titles.js +++ b/src/endpoints/titles.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class TitlesEndpoint extends AbstractEndpoint { +export class TitlesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/titles' diff --git a/src/endpoints/tokeninfo.js b/src/endpoints/tokeninfo.ts similarity index 54% rename from src/endpoints/tokeninfo.js rename to src/endpoints/tokeninfo.ts index 6157f1d..8bff10a 100644 --- a/src/endpoints/tokeninfo.js +++ b/src/endpoints/tokeninfo.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class TokeninfoEndpoint extends AbstractEndpoint { +export class TokeninfoEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/tokeninfo' diff --git a/src/endpoints/traits.js b/src/endpoints/traits.ts similarity index 62% rename from src/endpoints/traits.js rename to src/endpoints/traits.ts index a1f2167..a00fe30 100644 --- a/src/endpoints/traits.js +++ b/src/endpoints/traits.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class TraitsEndpoint extends AbstractEndpoint { +export class TraitsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/traits' diff --git a/src/endpoints/worldbosses.js b/src/endpoints/worldbosses.ts similarity index 62% rename from src/endpoints/worldbosses.js rename to src/endpoints/worldbosses.ts index 67d105c..b4c2a8a 100644 --- a/src/endpoints/worldbosses.js +++ b/src/endpoints/worldbosses.ts @@ -1,6 +1,6 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' -module.exports = class WorldbossesEndpoint extends AbstractEndpoint { +export class WorldbossesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/worldbosses' diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..75d41cf --- /dev/null +++ b/src/types.ts @@ -0,0 +1 @@ +export type ItemID = number From a7dbc2980cb49df922dc514100edf614590e18f2 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 22 Apr 2023 22:04:36 +0200 Subject: [PATCH 07/72] Remove superfluous explicit return types and public modifiers --- src/endpoints/continents.ts | 2 +- src/endpoints/emblem.ts | 4 ++-- src/endpoints/events.ts | 4 ++-- src/endpoints/guild.ts | 26 +++++++++++++------------- src/endpoints/home.ts | 4 ++-- src/endpoints/mounts.ts | 4 ++-- src/endpoints/recipes.ts | 6 +++--- src/endpoints/stories.ts | 2 +- src/endpoints/wvw.ts | 12 ++++++------ 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/endpoints/continents.ts b/src/endpoints/continents.ts index 6895a4a..5b623a8 100644 --- a/src/endpoints/continents.ts +++ b/src/endpoints/continents.ts @@ -12,7 +12,7 @@ export class ContinentsEndpoint extends AbstractEndpoint { this.cacheTime = 24 * 60 * 60 } - public floors (id: FloorID): FloorsEndpoint { + floors (id: FloorID) { return new FloorsEndpoint(this, id) } } diff --git a/src/endpoints/emblem.ts b/src/endpoints/emblem.ts index 73792e9..f11ade4 100644 --- a/src/endpoints/emblem.ts +++ b/src/endpoints/emblem.ts @@ -1,11 +1,11 @@ import { AbstractEndpoint } from '../endpoint' export class EmblemEndpoint extends AbstractEndpoint { - public backgrounds (): LayersEndpoint { + backgrounds () { return new LayersEndpoint(this, 'backgrounds') } - public foregrounds (): LayersEndpoint { + foregrounds () { return new LayersEndpoint(this, 'foregrounds') } } diff --git a/src/endpoints/events.ts b/src/endpoints/events.ts index 1eaf8bc..0c50958 100644 --- a/src/endpoints/events.ts +++ b/src/endpoints/events.ts @@ -9,11 +9,11 @@ export class EventsEndpoint extends AbstractEndpoint { this.cacheTime = 24 * 60 * 60 } - public all () { + all () { return super.get().then(transformV1Format) } - public get (id: EventID) { + get (id: EventID) { return super.get(`?event_id=${id}`, true).then(json => transformV1Format(json)[0]) } } diff --git a/src/endpoints/guild.ts b/src/endpoints/guild.ts index ed387aa..5314714 100644 --- a/src/endpoints/guild.ts +++ b/src/endpoints/guild.ts @@ -15,20 +15,20 @@ export class GuildEndpoint extends AbstractEndpoint { this.cacheTime = 60 * 60 } - public get (id: GuildID) { + get (id: GuildID) { return super.get(`/${id}`, true) } - public permissions (): PermissionsEndpoint { + permissions () { return new PermissionsEndpoint(this) } - public search (name: string): SearchEndpoint { + search (name: string) { // FIXME: bug? Constructor got passed `name` before (which is not received in the constructor) instead of chaining the call return new SearchEndpoint(this) //, name) } - public upgrades (): UpgradesEndpoint | AllUpgradesEndpoint { + upgrades () { if (this.id === undefined) { return new AllUpgradesEndpoint(this) } @@ -36,31 +36,31 @@ export class GuildEndpoint extends AbstractEndpoint { return new UpgradesEndpoint(this, this.id) } - public log (): LogEndpoint { + log () { return new LogEndpoint(this, this.id) } - public members (): MembersEndpoint { + members () { return new MembersEndpoint(this, this.id) } - public ranks (): RanksEndpoint { + ranks () { return new RanksEndpoint(this, this.id) } - public stash (): StashEndpoint { + stash () { return new StashEndpoint(this, this.id) } - public storage (): StorageEndpoint { + storage () { return new StorageEndpoint(this, this.id) } - public teams (): TeamsEndpoint { + teams () { return new TeamsEndpoint(this, this.id) } - public treasury (): TreasuryEndpoint { + treasury () { return new TreasuryEndpoint(this, this.id) } } @@ -83,7 +83,7 @@ class SearchEndpoint extends AbstractEndpoint { this.cacheTime = 60 * 60 } - public name (name: string) { + name (name: string) { return super.get(`?name=${encodeURIComponent(name)}`, true) .then(result => result[0]) } @@ -108,7 +108,7 @@ class LogEndpoint extends AbstractEndpoint { this.cacheTime = 5 * 60 } - public since (logId: LogID) { + since (logId: LogID) { return super.get(`?since=${logId}`, true) } } diff --git a/src/endpoints/home.ts b/src/endpoints/home.ts index 4b35671..52ea538 100644 --- a/src/endpoints/home.ts +++ b/src/endpoints/home.ts @@ -1,11 +1,11 @@ import { AbstractEndpoint } from '../endpoint' export class HomeEndpoint extends AbstractEndpoint { - public cats (): CatsEndpoint { + cats () { return new CatsEndpoint(this) } - public nodes (): NodesEndpoint { + nodes () { return new NodesEndpoint(this) } } diff --git a/src/endpoints/mounts.ts b/src/endpoints/mounts.ts index 7517995..27b1cf8 100644 --- a/src/endpoints/mounts.ts +++ b/src/endpoints/mounts.ts @@ -1,11 +1,11 @@ import { AbstractEndpoint } from '../endpoint' export class MountsEndpoint extends AbstractEndpoint { - public skins (): SkinsEndpoint { + skins () { return new SkinsEndpoint(this) } - public types (): TypesEndpoint { + types () { return new TypesEndpoint(this) } } diff --git a/src/endpoints/recipes.ts b/src/endpoints/recipes.ts index cacd942..2312ee1 100644 --- a/src/endpoints/recipes.ts +++ b/src/endpoints/recipes.ts @@ -12,7 +12,7 @@ export class RecipesEndpoint extends AbstractEndpoint { this.cacheTime = 24 * 60 * 60 } - public search (): SearchEndpoint { + search () { return new SearchEndpoint(this) } } @@ -24,11 +24,11 @@ class SearchEndpoint extends AbstractEndpoint { this.cacheTime = 24 * 60 * 60 } - public input (id: ItemID) { + input (id: ItemID) { return super.get(`?input=${id}`, true) } - public output (id: ItemID) { + output (id: ItemID) { return super.get(`?output=${id}`, true) } } diff --git a/src/endpoints/stories.ts b/src/endpoints/stories.ts index 71fac11..e22c4c9 100644 --- a/src/endpoints/stories.ts +++ b/src/endpoints/stories.ts @@ -10,7 +10,7 @@ export class StoriesEndpoint extends AbstractEndpoint { this.cacheTime = 24 * 60 * 60 } - public seasons (): SeasonsEndpoint { + seasons () { return new SeasonsEndpoint(this) } } diff --git a/src/endpoints/wvw.ts b/src/endpoints/wvw.ts index 2781421..78467f8 100644 --- a/src/endpoints/wvw.ts +++ b/src/endpoints/wvw.ts @@ -72,23 +72,23 @@ type WorldID = NA.WorldID | EU.WorldID export class WvwEndpoint extends AbstractEndpoint { - public abilities (): AbilitiesEndpoint { + abilities () { return new AbilitiesEndpoint(this) } - public matches (): MatchesEndpoint { + matches () { return new MatchesEndpoint(this) } - public objectives (): ObjectivesEndpoint { + objectives () { return new ObjectivesEndpoint(this) } - public upgrades (): UpgradesEndpoint { + upgrades () { return new UpgradesEndpoint(this) } - public ranks (): RanksEndpoint { + ranks () { return new RanksEndpoint(this) } } @@ -143,7 +143,7 @@ class TeamsEndpoint extends AbstractEndpoint { this.url = `/v2/wvw/matches/stats/${id}/teams` } - public top (which: Top): TopStatsEndpoint { + top (which: Top) { return new TopStatsEndpoint(this, this.id, this.team, which) } } From 4df86955cbbc8863e5859483ae56bf864debf483 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 23 Apr 2023 14:12:59 +0200 Subject: [PATCH 08/72] Move generic parameter from get() et al. to AbstractEndpoint --- src/endpoint.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/endpoint.ts b/src/endpoint.ts index 901b149..79a7bba 100644 --- a/src/endpoint.ts +++ b/src/endpoint.ts @@ -21,7 +21,7 @@ interface IDable { id: number } -export class AbstractEndpoint { +export class AbstractEndpoint { public client protected schemaVersion: string protected lang: Language @@ -144,9 +144,9 @@ export class AbstractEndpoint { } // Get a single entry by id - public async get (id: string, url: true): Promise; - public async get (id: number, url: false): Promise; - public async get (id: number | string, url: boolean = false): Promise { + public async get (id: string, url: true): Promise; + public async get (id: number, url: false): Promise; + public async get (id: number | string, url: boolean = false): Promise { this.debugMessage(`get(${this.url}) called`) if (!id && this.isBulk && !url) { @@ -199,7 +199,7 @@ export class AbstractEndpoint { } // Get multiple entries by ids - public async many (ids: number[]): Promise { + public async many (ids: number[]): Promise { this.debugMessage(`many(${this.url}) called (${ids.length} ids)`) if (!this.isBulk) { From 02f49982c04b73c3e17c4343992ef7e2b9b0aa38 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 23 Apr 2023 14:13:24 +0200 Subject: [PATCH 09/72] Define result types for achievement enpoints --- src/endpoints/achievements.ts | 106 ++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 5 deletions(-) diff --git a/src/endpoints/achievements.ts b/src/endpoints/achievements.ts index b9e445f..513e7f2 100644 --- a/src/endpoints/achievements.ts +++ b/src/endpoints/achievements.ts @@ -1,6 +1,101 @@ import { AbstractEndpoint } from '../endpoint' -export class AchievementsEndpoint extends AbstractEndpoint { + +type Flag = 'PvE' | 'PvP' | 'WvW' | 'SpecialEvent' +type Product = 'GuildWars2' | 'HeartOfThorns' | 'PathOfFire' | 'EndOfDragons' +type Condition = 'HasAccess' | 'NoAccess' +type LevelTuple = [number, number] +type LevelObj = { min: number, max: number } +type RequiredAccess = { product: Product, condition: Condition } + +export namespace SchemaOld { + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily} */ + type Daily = { + id: number, + level: LevelObj, + required_access: Product[] + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ + export interface Dailies { + pve: Daily[], + wvw: Daily[], + fractals: Daily[], + special: Daily[] + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/categories} */ + export interface Category { + id: number, + name: string, + description: string, + order: number, + icon: string, + achievements: number[], + } +} + +// If using schema 2019-05-16T00:00:00.000Z or later +export namespace SchemaNew { + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily} */ + type Daily = { + id: number, + level: LevelObj, + required_access?: RequiredAccess + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ + export interface Dailies { + pve: Daily[], + wvw: Daily[], + fractals: Daily[], + special: Daily[] + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/categories} */ + export interface Category { + id: number, + name: string, + description: string, + order: number, + icon: string, + achievements: { + id: number, + required_access: RequiredAccess + flags: Flag[], + level: [number, number] + }, + tomorrow: { + id: number, + required_access: RequiredAccess, + flags: Flag[], + level: LevelTuple + } + } +} + +/** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/groups} */ +interface Group { + id: string, + name: string, + description: string, + order: number, + categories: number[] +} + +/** {@link https://wiki.guildwars2.com/wiki/API:2/account/achievements} */ +interface Achievement { + id: number, + bits?: number, + current?: number, + max?: number, + done: boolean, + repeated?: number, + unlocked?: number +} + + +export class AchievementsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements' @@ -28,7 +123,7 @@ export class AchievementsEndpoint extends AbstractEndpoint { } } -class CategoriesEndpoint extends AbstractEndpoint { +class CategoriesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements/categories' @@ -39,7 +134,8 @@ class CategoriesEndpoint extends AbstractEndpoint { } } -class GroupsEndpoint extends AbstractEndpoint { + +class GroupsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements/groups' @@ -50,7 +146,7 @@ class GroupsEndpoint extends AbstractEndpoint { } } -class DailyEndpoint extends AbstractEndpoint { +class DailyEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements/daily' @@ -58,7 +154,7 @@ class DailyEndpoint extends AbstractEndpoint { } } -class DailyTomorrowEndpoint extends AbstractEndpoint { +class DailyTomorrowEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements/daily/tomorrow' From 65122e8fd7f52c703531365d1aef96c6dfe9e26a Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 23 Apr 2023 14:20:48 +0200 Subject: [PATCH 10/72] Add backstory types --- src/endpoints/backstory.ts | 34 +++++++++++++++++++++++++++++++--- src/types.ts | 3 +++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/endpoints/backstory.ts b/src/endpoints/backstory.ts index 71889eb..237f79f 100644 --- a/src/endpoints/backstory.ts +++ b/src/endpoints/backstory.ts @@ -1,6 +1,34 @@ import { AbstractEndpoint } from '../endpoint' +import { Profession, Race } from '../types' -export class BackstoryEndpoint extends AbstractEndpoint { +/** {@link https://wiki.guildwars2.com/wiki/API:2/characters/:id/backstory} */ +interface Backstory { + backstory: string[] +} + +/** {@link https://wiki.guildwars2.com/wiki/API:2/backstory/answers} */ +interface Answer { + id: string, + title: string, + description: string, + journal: string, + question: number, + professions: Profession[], + races: Race[], +} + +/** {@link https://wiki.guildwars2.com/wiki/API:2/backstory/questions} */ +interface Question { + id: number, + title: string, + description: string, + answer: number[], + order: number, + races: Race[], + professions: Profession[] +} + +export class BackstoryEndpoint extends AbstractEndpoint { answers () { return new AnswersEndpoint(this) } @@ -10,7 +38,7 @@ export class BackstoryEndpoint extends AbstractEndpoint { } } -class AnswersEndpoint extends AbstractEndpoint { +class AnswersEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/backstory/answers' @@ -22,7 +50,7 @@ class AnswersEndpoint extends AbstractEndpoint { } } -class QuestionsEndpoint extends AbstractEndpoint { +class QuestionsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/backstory/questions' diff --git a/src/types.ts b/src/types.ts index 75d41cf..9a5e299 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1 +1,4 @@ export type ItemID = number + +export type Race = 'Human' | 'Norn' | 'Charr' | 'Sylvari' | 'Asura' +export type Profession = 'Guardian' | 'Revenant' | 'Warrior' | 'Engineer' | 'Ranger' | 'Thief' | 'Elementalist' | 'Mesmer' | 'Necromancer' From db28cc7339435e75e21e724d28f7bcf63ae5123a Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 23 Apr 2023 14:59:44 +0200 Subject: [PATCH 11/72] Add result types for build endpoint --- src/endpoint.ts | 4 ++-- src/endpoints/build.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/endpoint.ts b/src/endpoint.ts index 79a7bba..bb6af3c 100644 --- a/src/endpoint.ts +++ b/src/endpoint.ts @@ -144,8 +144,8 @@ export class AbstractEndpoint { } // Get a single entry by id - public async get (id: string, url: true): Promise; - public async get (id: number, url: false): Promise; + public async get (id: string, url?: true): Promise; + public async get (id: number, url?: false): Promise; public async get (id: number | string, url: boolean = false): Promise { this.debugMessage(`get(${this.url}) called`) diff --git a/src/endpoints/build.ts b/src/endpoints/build.ts index afc766f..3666e65 100644 --- a/src/endpoints/build.ts +++ b/src/endpoints/build.ts @@ -1,6 +1,11 @@ import { AbstractEndpoint } from '../endpoint' -export class BuildEndpoint extends AbstractEndpoint { +/** {@link https://wiki.guildwars2.com/wiki/API:2/build} */ +interface Build { + id: number +} + +export class BuildEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/build' @@ -8,6 +13,7 @@ export class BuildEndpoint extends AbstractEndpoint { } get () { - return super.get().then(result => result.id) + // FIXME: bug? Formerly, no ID was passed, which would cause an error in the nullish check in super.get() + return super.get(-1).then(result => result.id) } } From a444ed6fe36b8419ae437bf3f219c66e7ecfc357 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 23 Apr 2023 22:05:57 +0200 Subject: [PATCH 12/72] Add color reponse type --- src/endpoints/cats.ts | 14 +++++++++++++- src/endpoints/colors.ts | 29 ++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/endpoints/cats.ts b/src/endpoints/cats.ts index 8dcf63b..4c667b8 100644 --- a/src/endpoints/cats.ts +++ b/src/endpoints/cats.ts @@ -1,6 +1,18 @@ import { AbstractEndpoint } from '../endpoint' -export class CatsEndpoint extends AbstractEndpoint { + +export namespace SchemaOld { + export interface Cat { + id: number, + hint: string + } +} + +export namespace SchemaNew { + export type Cat = number +} + +export class CatsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/cats' diff --git a/src/endpoints/colors.ts b/src/endpoints/colors.ts index 6a70436..c15a1f7 100644 --- a/src/endpoints/colors.ts +++ b/src/endpoints/colors.ts @@ -1,6 +1,33 @@ import { AbstractEndpoint } from '../endpoint' -export class ColorsEndpoint extends AbstractEndpoint { +type RGB = [number, number, number] +type Hue = 'Gray' | 'Brown' | 'Red' | 'Orange' | 'Yellow' | 'Green' | 'Blue' | 'Purple' +type Material = 'Vibrant' | 'Leather' | 'Metal' +type Rarity = 'Start' | 'Common' | 'Uncommon' | 'Rare' | 'Purple' +type Category = Hue | Material | Rarity + +interface Details { + brightness: number, + contrast: number, + hue: number, + saturation: number, + lightness: number, + rgb: RGB +} + +interface Color { + id: number, + name: string, + base_rgb: RGB, + cloth: Details, + leather: Details, + metal: Details, + fur?: Details, + item?: number + categories: Category[] +} + +export class ColorsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/colors' From a08d3b11930c49b5fb731517b83d322731389069 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Mon, 24 Apr 2023 19:07:41 +0200 Subject: [PATCH 13/72] Add dungeons endpoint --- src/endpoints/dungeons.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/endpoints/dungeons.ts b/src/endpoints/dungeons.ts index a5379de..3bb8a5c 100644 --- a/src/endpoints/dungeons.ts +++ b/src/endpoints/dungeons.ts @@ -1,6 +1,12 @@ import { AbstractEndpoint } from '../endpoint' -export class DungeonsEndpoint extends AbstractEndpoint { + +interface Dungeon { + id: string, + paths: { id: string, type: 'Story' | 'Explorable' } +} + +export class DungeonsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/dungeons' From e5b259736bc5ef37edc457988eb3ec64b2d83955 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Mon, 24 Apr 2023 19:09:18 +0200 Subject: [PATCH 14/72] Add continent endpoint --- src/endpoints/continents.ts | 104 +++++++++++++++++++++++++++++++++++- src/types.ts | 1 + 2 files changed, 103 insertions(+), 2 deletions(-) diff --git a/src/endpoints/continents.ts b/src/endpoints/continents.ts index 5b623a8..06118b3 100644 --- a/src/endpoints/continents.ts +++ b/src/endpoints/continents.ts @@ -1,8 +1,108 @@ import { AbstractEndpoint } from '../endpoint' type FloorID = number +type Dim = [number, number] +type Coordinate = [number, number] +type Rectangle = [Dim, Dim] -export class ContinentsEndpoint extends AbstractEndpoint { +interface Continent { + id: number, + name: 'Tyria' | 'Mists', + continent_dims: Dim, + min_zoom: number, + max_zoom: number, + floors: number[] +} + +interface Floor { + texture_dims: Dim, + clamped_view: Rectangle, + regions: { [key: number]: Region } +} + +interface Region { + name: string, + label_coord: Coordinate, + continent_rect: Rectangle, + maps: { [key: number]: MapInfo } +} + +interface MapInfo { + name: string, + min_level: number, + max_level: number, + default_floor: number, + label_coord: Coordinate, + map_rect: Rectangle, + continent_rect: Rectangle, + points_of_interest: PointOfInterest[], + tasks: Task[], + skill_challenges: SkillChallenge[], + sectors: Sector[], + adventures: Adventure[], + mastery_points: MasteryPoint[] +} + +interface Task { + objective: string, + level: number, + coord: Coordinate, + bounds: Coordinate[], + id: number, + chat_link: string +} + +interface SkillChallenge { + coord: Coordinate, + id: string +} + +interface Sector { + name: string, + level: number, + coord: Coordinate, + bounds: Coordinate[], + chat_link: String, + id: number +} + + +interface Adventure { + coord: Coordinate, + id: string, + name: string, + description: string +} + + + +interface MasteryPoint { + coord: Coordinate, + id: number, + region: Region, + +} + +interface PoI { + name: string, + type: T, + floor: number, + coord: Dim, + id: number, + chat_link: string +} + +interface Landmark extends PoI<'landmark'> {} +interface Waypoint extends PoI<'waypoint'> {} +interface Vista extends PoI<'vista'> {} +interface Unlock extends PoI<'unlock'> { chat_link: string } +type PointOfInterest = Landmark | Waypoint | Vista | Unlock + + + + + +export class ContinentsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/continents' @@ -17,7 +117,7 @@ export class ContinentsEndpoint extends AbstractEndpoint { } } -class FloorsEndpoint extends AbstractEndpoint { +class FloorsEndpoint extends AbstractEndpoint { constructor (client, continentId) { super(client) this.url = `/v2/continents/${continentId}/floors` diff --git a/src/types.ts b/src/types.ts index 9a5e299..37f2da8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,3 +2,4 @@ export type ItemID = number export type Race = 'Human' | 'Norn' | 'Charr' | 'Sylvari' | 'Asura' export type Profession = 'Guardian' | 'Revenant' | 'Warrior' | 'Engineer' | 'Ranger' | 'Thief' | 'Elementalist' | 'Mesmer' | 'Necromancer' +export type Region = 'Tyria' | 'Maguuma' | 'Desert' | 'Tundra' \ No newline at end of file From 353c7b16ae728b1fc51b8c70cb971bb82aece4da Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Mon, 24 Apr 2023 19:34:47 +0200 Subject: [PATCH 15/72] Add currency endpoint --- src/endpoints/currencies.ts | 11 ++++++++++- src/types.ts | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/endpoints/currencies.ts b/src/endpoints/currencies.ts index fd9218f..ee1b66b 100644 --- a/src/endpoints/currencies.ts +++ b/src/endpoints/currencies.ts @@ -1,6 +1,15 @@ import { AbstractEndpoint } from '../endpoint' +import { URL } from '../types' -export class CurrenciesEndpoint extends AbstractEndpoint { +interface Currency { + id: number, + string: string, + description: string, + icon: URL, + order: number +} + +export class CurrenciesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/currencies' diff --git a/src/types.ts b/src/types.ts index 37f2da8..77c0358 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,7 @@ export type ItemID = number +export type URL = string + export type Race = 'Human' | 'Norn' | 'Charr' | 'Sylvari' | 'Asura' export type Profession = 'Guardian' | 'Revenant' | 'Warrior' | 'Engineer' | 'Ranger' | 'Thief' | 'Elementalist' | 'Mesmer' | 'Necromancer' export type Region = 'Tyria' | 'Maguuma' | 'Desert' | 'Tundra' \ No newline at end of file From 3f0d34735ae112819bda0b4ae2a3c57440a21b60 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Mon, 24 Apr 2023 19:36:43 +0200 Subject: [PATCH 16/72] Add daily crafting endpoint --- src/endpoints/dailycrafting.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/endpoints/dailycrafting.ts b/src/endpoints/dailycrafting.ts index b78d05c..df4dca3 100644 --- a/src/endpoints/dailycrafting.ts +++ b/src/endpoints/dailycrafting.ts @@ -1,6 +1,8 @@ import { AbstractEndpoint } from '../endpoint' -export class DailycraftingEndpoint extends AbstractEndpoint { +type DailyCrafting = 'lump_of_mithrilium' | 'spool_of_silk_weaving_thread' | 'spool_of_thick_elonian_cord' + +export class DailycraftingEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/dailycrafting' From 81362ef73a60d24cd1b244065614fc78d3dbd3d1 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Mon, 24 Apr 2023 23:08:08 +0200 Subject: [PATCH 17/72] Add new schema logic and migrate several endpoints (WIP) --- src/{client.js => client.ts} | 41 ++++--- src/endpoint.ts | 8 +- src/endpoints/account.ts | 3 +- src/endpoints/achievements.ts | 11 +- src/endpoints/backstory.ts | 39 +------ src/endpoints/build.ts | 11 +- src/endpoints/cats.ts | 15 +-- src/endpoints/characters.ts | 6 +- src/endpoints/colors.ts | 30 +---- src/endpoints/continents.ts | 102 ----------------- src/endpoints/dailycrafting.ts | 5 +- src/endpoints/dungeons.ts | 11 +- src/endpoints/index.ts | 104 +++++++++--------- .../schemas/responses/achievements.ts | 35 ++++++ src/endpoints/schemas/responses/backstory.ts | 28 +++++ src/endpoints/schemas/responses/colors.ts | 26 +++++ src/endpoints/schemas/responses/continents.ts | 94 ++++++++++++++++ .../schemas/responses/dailycrafting.ts | 1 + src/endpoints/schemas/responses/dungeons.ts | 7 ++ src/endpoints/schemas/schema.ts | 59 ++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 44 ++++++++ src/endpoints/schemas/schema_2019_02_21.ts | 5 + src/endpoints/schemas/schema_2019_03_22.ts | 5 + src/endpoints/schemas/schema_2019_05_16.ts | 17 +++ src/endpoints/schemas/schema_2019_05_21.ts | 5 + src/endpoints/schemas/schema_2019_05_22.ts | 5 + src/endpoints/schemas/schema_2019_12_19.ts | 5 + src/endpoints/schemas/schema_2020_11_17.ts | 5 + src/endpoints/schemas/schema_2021_04_06.ts | 5 + src/endpoints/schemas/schema_2021_07_15.ts | 5 + src/endpoints/schemas/schema_2022_03_09.ts | 5 + src/endpoints/schemas/schema_2022_03_23.ts | 28 +++++ src/types.ts | 1 + 33 files changed, 493 insertions(+), 278 deletions(-) rename src/{client.js => client.ts} (87%) create mode 100644 src/endpoints/schemas/responses/achievements.ts create mode 100644 src/endpoints/schemas/responses/backstory.ts create mode 100644 src/endpoints/schemas/responses/colors.ts create mode 100644 src/endpoints/schemas/responses/continents.ts create mode 100644 src/endpoints/schemas/responses/dailycrafting.ts create mode 100644 src/endpoints/schemas/responses/dungeons.ts create mode 100644 src/endpoints/schemas/schema.ts create mode 100644 src/endpoints/schemas/schema_1970_01_01.ts create mode 100644 src/endpoints/schemas/schema_2019_02_21.ts create mode 100644 src/endpoints/schemas/schema_2019_03_22.ts create mode 100644 src/endpoints/schemas/schema_2019_05_16.ts create mode 100644 src/endpoints/schemas/schema_2019_05_21.ts create mode 100644 src/endpoints/schemas/schema_2019_05_22.ts create mode 100644 src/endpoints/schemas/schema_2019_12_19.ts create mode 100644 src/endpoints/schemas/schema_2020_11_17.ts create mode 100644 src/endpoints/schemas/schema_2021_04_06.ts create mode 100644 src/endpoints/schemas/schema_2021_07_15.ts create mode 100644 src/endpoints/schemas/schema_2022_03_09.ts create mode 100644 src/endpoints/schemas/schema_2022_03_23.ts diff --git a/src/client.js b/src/client.ts similarity index 87% rename from src/client.js rename to src/client.ts index 44af45a..010656d 100644 --- a/src/client.js +++ b/src/client.ts @@ -1,55 +1,60 @@ const fetch = require('lets-fetch') const nullCache = require('./cache/null') -const endpoints = require('./endpoints') +import * as endpoints from './endpoints/index' +import { Schema } from './endpoints/schemas/schema' +import { Language } from './types' const flow = require('./flow') -module.exports = class Client { +export class Client { + private schemaVersion = '2019-03-20T00:00:00.000Z' + private lang: Language = 'en' + private fetch = fetch + private caches = [nullCache()] + private debug = false + private client: Client + private apiKey: string + constructor () { - this.schemaVersion = '2019-03-20T00:00:00.000Z' - this.lang = 'en' - this.apiKey = false - this.fetch = fetch - this.caches = [nullCache()] - this.debug = false this.client = this } // Set the schema version - schema (schema) { + schema (schema: string) { this.schemaVersion = schema this.debugMessage(`set the schema to ${schema}`) return this } // Set the language for locale-aware endpoints - language (lang) { + language (lang: Language) { this.lang = lang this.debugMessage(`set the language to ${lang}`) return this } // Set the api key for authenticated endpoints - authenticate (apiKey) { + authenticate (apiKey: string) { this.apiKey = apiKey this.debugMessage(`set the api key to ${apiKey}`) return this } // Set the caching storage method(s) - cacheStorage (caches) { + // FIXME: type + cacheStorage (caches: any[]) { this.caches = [].concat(caches) this.debugMessage(`updated the cache storage`) return this } // Set the debugging flag - debugging (flag) { + debugging (flag: boolean) { this.debug = flag return this } // Print out a debug message if debugging is enabled - debugMessage (string) { + debugMessage (string: string) { if (this.debug) { console.log(`[gw2api-client] ${string}`) } @@ -81,15 +86,15 @@ module.exports = class Client { // All the different API endpoints account () { - return new endpoints.AccountEndpoint(this) + return new endpoints.AccountEndpoint(this) } achievements () { - return new endpoints.AchievementsEndpoint(this) + return new endpoints.AchievementsEndpoint(this) } backstory () { - return new endpoints.BackstoryEndpoint(this) + return new endpoints.BackstoryEndpoint(this) } build () { @@ -283,4 +288,4 @@ module.exports = class Client { wvw () { return new endpoints.WvwEndpoint(this) } -} +} \ No newline at end of file diff --git a/src/endpoint.ts b/src/endpoint.ts index bb6af3c..9145ecd 100644 --- a/src/endpoint.ts +++ b/src/endpoint.ts @@ -1,3 +1,5 @@ +import { Language, URL } from "./types" + const qs = require('querystringify') const unique = require('array-unique') const chunk = require('chunk') @@ -6,10 +8,6 @@ const hashString = require('./hash') // FIXME: replace with structuredClone? const clone = (x: T): T => JSON.parse(JSON.stringify(x)) - -type Language = 'en' | 'de' | 'es' | 'fr' -type Url = string - interface Headers { headers: { get: (prop: string) => T @@ -29,7 +27,7 @@ export class AbstractEndpoint { protected fetch protected caches protected debug - protected baseUrl: Url = 'https://api.guildwars2.com' + protected baseUrl: URL = 'https://api.guildwars2.com' protected isPaginated = false protected maxPageSize = 200 protected isBulk = false diff --git a/src/endpoints/account.ts b/src/endpoints/account.ts index 0306f89..94b4b6e 100644 --- a/src/endpoints/account.ts +++ b/src/endpoints/account.ts @@ -1,11 +1,12 @@ import { AbstractEndpoint } from '../endpoint' +import { Schema } from './schemas/schema' const CharactersEndpoint = require('./characters') const PvpEndpoint = require('./pvp') const CommerceEndpoint = require('./commerce') const accountBlob = require('./account-blob.js') const resetTime = require('../helpers/resetTime') -export class AccountEndpoint extends AbstractEndpoint { +export class AccountEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/account' diff --git a/src/endpoints/achievements.ts b/src/endpoints/achievements.ts index 513e7f2..9e5a631 100644 --- a/src/endpoints/achievements.ts +++ b/src/endpoints/achievements.ts @@ -1,4 +1,5 @@ import { AbstractEndpoint } from '../endpoint' +import { Schema } from './schemas/schema' type Flag = 'PvE' | 'PvP' | 'WvW' | 'SpecialEvent' @@ -95,7 +96,7 @@ interface Achievement { } -export class AchievementsEndpoint extends AbstractEndpoint { +export class AchievementsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements' @@ -123,7 +124,7 @@ export class AchievementsEndpoint extends AbstractEndpoint { } } -class CategoriesEndpoint extends AbstractEndpoint { +class CategoriesEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements/categories' @@ -135,7 +136,7 @@ class CategoriesEndpoint exte } -class GroupsEndpoint extends AbstractEndpoint { +class GroupsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements/groups' @@ -146,7 +147,7 @@ class GroupsEndpoint extends AbstractEndpoint { } } -class DailyEndpoint extends AbstractEndpoint { +class DailyEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements/daily' @@ -154,7 +155,7 @@ class DailyEndpoint extends Abs } } -class DailyTomorrowEndpoint extends AbstractEndpoint { +class DailyTomorrowEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements/daily/tomorrow' diff --git a/src/endpoints/backstory.ts b/src/endpoints/backstory.ts index 237f79f..c10d2e8 100644 --- a/src/endpoints/backstory.ts +++ b/src/endpoints/backstory.ts @@ -1,44 +1,17 @@ import { AbstractEndpoint } from '../endpoint' -import { Profession, Race } from '../types' +import { Schema } from './schemas/schema' -/** {@link https://wiki.guildwars2.com/wiki/API:2/characters/:id/backstory} */ -interface Backstory { - backstory: string[] -} - -/** {@link https://wiki.guildwars2.com/wiki/API:2/backstory/answers} */ -interface Answer { - id: string, - title: string, - description: string, - journal: string, - question: number, - professions: Profession[], - races: Race[], -} - -/** {@link https://wiki.guildwars2.com/wiki/API:2/backstory/questions} */ -interface Question { - id: number, - title: string, - description: string, - answer: number[], - order: number, - races: Race[], - professions: Profession[] -} - -export class BackstoryEndpoint extends AbstractEndpoint { +export class BackstoryEndpoint extends AbstractEndpoint { answers () { - return new AnswersEndpoint(this) + return new AnswersEndpoint(this) } questions () { - return new QuestionsEndpoint(this) + return new QuestionsEndpoint(this) } } -class AnswersEndpoint extends AbstractEndpoint { +class AnswersEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/backstory/answers' @@ -50,7 +23,7 @@ class AnswersEndpoint extends AbstractEndpoint { } } -class QuestionsEndpoint extends AbstractEndpoint { +class QuestionsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/backstory/questions' diff --git a/src/endpoints/build.ts b/src/endpoints/build.ts index 3666e65..28b0fd3 100644 --- a/src/endpoints/build.ts +++ b/src/endpoints/build.ts @@ -1,18 +1,15 @@ import { AbstractEndpoint } from '../endpoint' +import { Schema } from './schemas/schema' -/** {@link https://wiki.guildwars2.com/wiki/API:2/build} */ -interface Build { - id: number -} - -export class BuildEndpoint extends AbstractEndpoint { +// FIXME: move id into superclass somewhere +export class BuildEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/build' this.cacheTime = 60 } - get () { + get (): Promise { // FIXME: bug? Formerly, no ID was passed, which would cause an error in the nullish check in super.get() return super.get(-1).then(result => result.id) } diff --git a/src/endpoints/cats.ts b/src/endpoints/cats.ts index 4c667b8..44e8d8e 100644 --- a/src/endpoints/cats.ts +++ b/src/endpoints/cats.ts @@ -1,18 +1,7 @@ import { AbstractEndpoint } from '../endpoint' +import { Schema } from './schemas/schema' - -export namespace SchemaOld { - export interface Cat { - id: number, - hint: string - } -} - -export namespace SchemaNew { - export type Cat = number -} - -export class CatsEndpoint extends AbstractEndpoint { +export class CatsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/cats' diff --git a/src/endpoints/characters.ts b/src/endpoints/characters.ts index 8d9d241..f797f20 100644 --- a/src/endpoints/characters.ts +++ b/src/endpoints/characters.ts @@ -1,6 +1,8 @@ -const AbstractEndpoint = require('../endpoint') +import { AbstractEndpoint } from '../endpoint' + +export class CharactersEndpoint extends AbstractEndpoint { + public name: string -module.exports = class CharactersEndpoint extends AbstractEndpoint { constructor (client, name) { super(client) this.name = name diff --git a/src/endpoints/colors.ts b/src/endpoints/colors.ts index c15a1f7..b28e4e0 100644 --- a/src/endpoints/colors.ts +++ b/src/endpoints/colors.ts @@ -1,33 +1,7 @@ import { AbstractEndpoint } from '../endpoint' +import { Schema } from './schemas/schema' -type RGB = [number, number, number] -type Hue = 'Gray' | 'Brown' | 'Red' | 'Orange' | 'Yellow' | 'Green' | 'Blue' | 'Purple' -type Material = 'Vibrant' | 'Leather' | 'Metal' -type Rarity = 'Start' | 'Common' | 'Uncommon' | 'Rare' | 'Purple' -type Category = Hue | Material | Rarity - -interface Details { - brightness: number, - contrast: number, - hue: number, - saturation: number, - lightness: number, - rgb: RGB -} - -interface Color { - id: number, - name: string, - base_rgb: RGB, - cloth: Details, - leather: Details, - metal: Details, - fur?: Details, - item?: number - categories: Category[] -} - -export class ColorsEndpoint extends AbstractEndpoint { +export class ColorsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/colors' diff --git a/src/endpoints/continents.ts b/src/endpoints/continents.ts index 06118b3..daa8ab6 100644 --- a/src/endpoints/continents.ts +++ b/src/endpoints/continents.ts @@ -1,107 +1,5 @@ import { AbstractEndpoint } from '../endpoint' -type FloorID = number -type Dim = [number, number] -type Coordinate = [number, number] -type Rectangle = [Dim, Dim] - -interface Continent { - id: number, - name: 'Tyria' | 'Mists', - continent_dims: Dim, - min_zoom: number, - max_zoom: number, - floors: number[] -} - -interface Floor { - texture_dims: Dim, - clamped_view: Rectangle, - regions: { [key: number]: Region } -} - -interface Region { - name: string, - label_coord: Coordinate, - continent_rect: Rectangle, - maps: { [key: number]: MapInfo } -} - -interface MapInfo { - name: string, - min_level: number, - max_level: number, - default_floor: number, - label_coord: Coordinate, - map_rect: Rectangle, - continent_rect: Rectangle, - points_of_interest: PointOfInterest[], - tasks: Task[], - skill_challenges: SkillChallenge[], - sectors: Sector[], - adventures: Adventure[], - mastery_points: MasteryPoint[] -} - -interface Task { - objective: string, - level: number, - coord: Coordinate, - bounds: Coordinate[], - id: number, - chat_link: string -} - -interface SkillChallenge { - coord: Coordinate, - id: string -} - -interface Sector { - name: string, - level: number, - coord: Coordinate, - bounds: Coordinate[], - chat_link: String, - id: number -} - - -interface Adventure { - coord: Coordinate, - id: string, - name: string, - description: string -} - - - -interface MasteryPoint { - coord: Coordinate, - id: number, - region: Region, - -} - -interface PoI { - name: string, - type: T, - floor: number, - coord: Dim, - id: number, - chat_link: string -} - -interface Landmark extends PoI<'landmark'> {} -interface Waypoint extends PoI<'waypoint'> {} -interface Vista extends PoI<'vista'> {} -interface Unlock extends PoI<'unlock'> { chat_link: string } -type PointOfInterest = Landmark | Waypoint | Vista | Unlock - - - - - export class ContinentsEndpoint extends AbstractEndpoint { constructor (client) { super(client) diff --git a/src/endpoints/dailycrafting.ts b/src/endpoints/dailycrafting.ts index df4dca3..0ee5c8e 100644 --- a/src/endpoints/dailycrafting.ts +++ b/src/endpoints/dailycrafting.ts @@ -1,8 +1,7 @@ import { AbstractEndpoint } from '../endpoint' +import { Schema } from './schemas/schema' -type DailyCrafting = 'lump_of_mithrilium' | 'spool_of_silk_weaving_thread' | 'spool_of_thick_elonian_cord' - -export class DailycraftingEndpoint extends AbstractEndpoint { +export class DailycraftingEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/dailycrafting' diff --git a/src/endpoints/dungeons.ts b/src/endpoints/dungeons.ts index 3bb8a5c..8f13a0e 100644 --- a/src/endpoints/dungeons.ts +++ b/src/endpoints/dungeons.ts @@ -1,12 +1,7 @@ import { AbstractEndpoint } from '../endpoint' +import { Schema } from './schemas/schema' - -interface Dungeon { - id: string, - paths: { id: string, type: 'Story' | 'Explorable' } -} - -export class DungeonsEndpoint extends AbstractEndpoint { +export class DungeonsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/dungeons' @@ -14,4 +9,4 @@ export class DungeonsEndpoint extends AbstractEndpoint { this.isBulk = true this.cacheTime = 24 * 60 * 60 } -} +} \ No newline at end of file diff --git a/src/endpoints/index.ts b/src/endpoints/index.ts index aabf021..06cee89 100644 --- a/src/endpoints/index.ts +++ b/src/endpoints/index.ts @@ -1,53 +1,51 @@ -module.exports = { - AccountEndpoint: require('./account'), - AchievementsEndpoint: require('./achievements'), - BackstoryEndpoint: require('./backstory'), - BuildEndpoint: require('./build'), - CatsEndpoint: require('./cats'), - CharactersEndpoint: require('./characters'), - ColorsEndpoint: require('./colors'), - CommerceEndpoint: require('./commerce'), - ContinentsEndpoint: require('./continents'), - CurrenciesEndpoint: require('./currencies'), - DailycraftingEndpoint: require('./dailycrafting'), - DungeonsEndpoint: require('./dungeons'), - EmblemEndpoint: require('./emblem'), - EventsEndpoint: require('./events'), - FilesEndpoint: require('./files'), - FinishersEndpoint: require('./finishers'), - GlidersEndpoint: require('./gliders'), - GuildEndpoint: require('./guild'), - HomeEndpoint: require('./home'), - ItemsEndpoint: require('./items'), - ItemstatsEndpoint: require('./itemstats'), - LegendaryarmoryEndpoint: require('./legendaryarmory'), - LegendsEndpoint: require('./legends'), - MailcarriersEndpoint: require('./mailcarriers'), - MapchestsEndpoint: require('./mapchests'), - MapsEndpoint: require('./maps'), - MasteriesEndpoint: require('./masteries'), - MaterialsEndpoint: require('./materials'), - MinisEndpoint: require('./minis'), - MountsEndpoint: require('./mounts'), - NodesEndpoint: require('./nodes'), - NoveltiesEndpoint: require('./novelties'), - OutfitsEndpoint: require('./outfits'), - PetsEndpoint: require('./pets'), - ProfessionsEndpoint: require('./professions'), - PvpEndpoint: require('./pvp'), - QuaggansEndpoint: require('./quaggans'), - QuestsEndpoint: require('./quests'), - RacesEndpoint: require('./races'), - RaidsEndpoint: require('./raids'), - RecipesEndpoint: require('./recipes'), - SkillsEndpoint: require('./skills'), - SkinsEndpoint: require('./skins'), - SpecializationsEndpoint: require('./specializations'), - StoriesEndpoint: require('./stories'), - TitlesEndpoint: require('./titles'), - TokeninfoEndpoint: require('./tokeninfo'), - TraitsEndpoint: require('./traits'), - WorldbossesEndpoint: require('./worldbosses'), - WorldsEndpoint: require('./worlds'), - WvwEndpoint: require('./wvw') -} +export { AccountEndpoint } from './account' +export { AchievementsEndpoint } from './achievements' +export { BackstoryEndpoint } from './backstory' +export { BuildEndpoint } from './build' +export { CatsEndpoint } from './cats' +export { CharactersEndpoint } from './characters' +export { ColorsEndpoint } from './colors' +export { CommerceEndpoint } from './commerce' +export { ContinentsEndpoint } from './continents' +export { CurrenciesEndpoint } from './currencies' +export { DailycraftingEndpoint } from './dailycrafting' +export { DungeonsEndpoint } from './dungeons' +export { EmblemEndpoint } from './emblem' +export { EventsEndpoint } from './events' +export { FilesEndpoint } from './files' +export { FinishersEndpoint } from './finishers' +export { GlidersEndpoint } from './gliders' +export { GuildEndpoint } from './guild' +export { HomeEndpoint } from './home' +export { ItemsEndpoint } from './items' +export { ItemstatsEndpoint } from './itemstats' +export { LegendaryarmoryEndpoint } from './legendaryarmory' +export { LegendsEndpoint } from './legends' +export { MailcarriersEndpoint } from './mailcarriers' +export { MapchestsEndpoint } from './mapchests' +export { MapsEndpoint } from './maps' +export { MasteriesEndpoint } from './masteries' +export { MaterialsEndpoint } from './materials' +export { MinisEndpoint } from './minis' +export { MountsEndpoint } from './mounts' +export { NodesEndpoint } from './nodes' +export { NoveltiesEndpoint } from './novelties' +export { OutfitsEndpoint } from './outfits' +export { PetsEndpoint } from './pets' +export { ProfessionsEndpoint } from './professions' +export { PvpEndpoint } from './pvp' +export { QuaggansEndpoint } from './quaggans' +export { QuestsEndpoint } from './quests' +export { RacesEndpoint } from './races' +export { RaidsEndpoint } from './raids' +export { RecipesEndpoint } from './recipes' +export { SkillsEndpoint } from './skills' +export { SkinsEndpoint } from './skins' +export { SpecializationsEndpoint } from './specializations' +export { StoriesEndpoint } from './stories' +export { TitlesEndpoint } from './titles' +export { TokeninfoEndpoint } from './tokeninfo' +export { TraitsEndpoint } from './traits' +export { WorldbossesEndpoint } from './worldbosses' +export { WorldsEndpoint } from './worlds' +export { WvwEndpoint } from './wvw' diff --git a/src/endpoints/schemas/responses/achievements.ts b/src/endpoints/schemas/responses/achievements.ts new file mode 100644 index 0000000..f034567 --- /dev/null +++ b/src/endpoints/schemas/responses/achievements.ts @@ -0,0 +1,35 @@ +export type Flag = 'PvE' | 'PvP' | 'WvW' | 'SpecialEvent' +export type Product = 'GuildWars2' | 'HeartOfThorns' | 'PathOfFire' | 'EndOfDragons' +export type Condition = 'HasAccess' | 'NoAccess' +export type LevelTuple = [number, number] +export type LevelObj = { min: number, max: number } +export type RequiredAccess = { product: Product, condition: Condition } + +/** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily} */ +export interface BaseDaily { + id: number, + level: LevelObj, +} + +/** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/categories} */ +export interface BaseCategory {} + +/** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/groups} */ +export interface Group { + id: string, + name: string, + description: string, + order: number, + categories: number[] +} + +/** {@link https://wiki.guildwars2.com/wiki/API:2/account/achievements} */ +export interface Achievement { + id: number, + bits?: number, + current?: number, + max?: number, + done: boolean, + repeated?: number, + unlocked?: number +} diff --git a/src/endpoints/schemas/responses/backstory.ts b/src/endpoints/schemas/responses/backstory.ts new file mode 100644 index 0000000..bbb209c --- /dev/null +++ b/src/endpoints/schemas/responses/backstory.ts @@ -0,0 +1,28 @@ +import { Profession, Race } from "../../../types" + +/** {@link https://wiki.guildwars2.com/wiki/API:2/characters/:id/backstory} */ +interface Backstory { + backstory: string[] + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/backstory/answers} */ + interface Answer { + id: string, + title: string, + description: string, + journal: string, + question: number, + professions: Profession[], + races: Race[], + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/backstory/questions} */ + interface Question { + id: number, + title: string, + description: string, + answer: number[], + order: number, + races: Race[], + professions: Profession[] + } \ No newline at end of file diff --git a/src/endpoints/schemas/responses/colors.ts b/src/endpoints/schemas/responses/colors.ts new file mode 100644 index 0000000..158b163 --- /dev/null +++ b/src/endpoints/schemas/responses/colors.ts @@ -0,0 +1,26 @@ +export type RGB = [number, number, number] +export type Hue = 'Gray' | 'Brown' | 'Red' | 'Orange' | 'Yellow' | 'Green' | 'Blue' | 'Purple' +export type Material = 'Vibrant' | 'Leather' | 'Metal' +export type Rarity = 'Start' | 'Common' | 'Uncommon' | 'Rare' | 'Purple' +export type Category = Hue | Material | Rarity + +export interface Details { + brightness: number, + contrast: number, + hue: number, + saturation: number, + lightness: number, + rgb: RGB +} + +export interface Color { + id: number, + name: string, + base_rgb: RGB, + cloth: Details, + leather: Details, + metal: Details, + fur?: Details, + item?: number + categories: Category[] +} \ No newline at end of file diff --git a/src/endpoints/schemas/responses/continents.ts b/src/endpoints/schemas/responses/continents.ts new file mode 100644 index 0000000..6e90984 --- /dev/null +++ b/src/endpoints/schemas/responses/continents.ts @@ -0,0 +1,94 @@ +type FloorID = number +type Dim = [number, number] +type Coordinate = [number, number] +type Rectangle = [Dim, Dim] + +interface Continent { + id: number, + name: 'Tyria' | 'Mists', + continent_dims: Dim, + min_zoom: number, + max_zoom: number, + floors: number[] +} + +interface Floor { + texture_dims: Dim, + clamped_view: Rectangle, + regions: { [key: number]: Region } +} + +interface Region { + name: string, + label_coord: Coordinate, + continent_rect: Rectangle, + maps: { [key: number]: MapInfo } +} + +interface MapInfo { + name: string, + min_level: number, + max_level: number, + default_floor: number, + label_coord: Coordinate, + map_rect: Rectangle, + continent_rect: Rectangle, + points_of_interest: PointOfInterest[], + tasks: Task[], + skill_challenges: SkillChallenge[], + sectors: Sector[], + adventures: Adventure[], + mastery_points: MasteryPoint[] +} + +interface Task { + objective: string, + level: number, + coord: Coordinate, + bounds: Coordinate[], + id: number, + chat_link: string +} + +interface SkillChallenge { + coord: Coordinate, + id: string +} + +interface Sector { + name: string, + level: number, + coord: Coordinate, + bounds: Coordinate[], + chat_link: String, + id: number +} + +interface Adventure { + coord: Coordinate, + id: string, + name: string, + description: string +} + +interface MasteryPoint { + coord: Coordinate, + id: number, + region: Region, + +} + +interface PoI { + name: string, + type: T, + floor: number, + coord: Dim, + id: number, + chat_link: string +} + +interface Landmark extends PoI<'landmark'> {} +interface Waypoint extends PoI<'waypoint'> {} +interface Vista extends PoI<'vista'> {} +interface Unlock extends PoI<'unlock'> { chat_link: string } +type PointOfInterest = Landmark | Waypoint | Vista | Unlock \ No newline at end of file diff --git a/src/endpoints/schemas/responses/dailycrafting.ts b/src/endpoints/schemas/responses/dailycrafting.ts new file mode 100644 index 0000000..893f07d --- /dev/null +++ b/src/endpoints/schemas/responses/dailycrafting.ts @@ -0,0 +1 @@ +type DailyCrafting = 'lump_of_mithrilium' | 'spool_of_silk_weaving_thread' | 'spool_of_thick_elonian_cord' \ No newline at end of file diff --git a/src/endpoints/schemas/responses/dungeons.ts b/src/endpoints/schemas/responses/dungeons.ts new file mode 100644 index 0000000..a29a349 --- /dev/null +++ b/src/endpoints/schemas/responses/dungeons.ts @@ -0,0 +1,7 @@ +interface Dungeon { + id: string, + paths: { + id: string, + type: 'Story' | 'Explorable' + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema.ts b/src/endpoints/schemas/schema.ts new file mode 100644 index 0000000..3e6640d --- /dev/null +++ b/src/endpoints/schemas/schema.ts @@ -0,0 +1,59 @@ +export interface EndpointResponse {} + +export interface Schema { + Account: EndpointResponse, + Achievements: EndpointResponse, + Answers: EndpointResponse, + Backstory: EndpointResponse, + Build: EndpointResponse, + Cats: EndpointResponse, + Characters: EndpointResponse, + Colors: EndpointResponse, + Commerce: EndpointResponse, + Continents: EndpointResponse, + Currencies: EndpointResponse, + Dailycrafting: EndpointResponse, + Dungeons: EndpointResponse, + Emblem: EndpointResponse, + Events: EndpointResponse, + Files: EndpointResponse, + Finishers: EndpointResponse, + Gliders: EndpointResponse, + Guild: EndpointResponse, + Home: EndpointResponse, + Items: EndpointResponse, + Itemstats: EndpointResponse, + Legendaryarmory: EndpointResponse, + Legends: EndpointResponse, + Mailcarriers: EndpointResponse, + Mapchests: EndpointResponse, + Maps: EndpointResponse, + Masteries: EndpointResponse, + Materials: EndpointResponse, + Minis: EndpointResponse, + Mounts: EndpointResponse, + Nodes: EndpointResponse, + Novelties: EndpointResponse, + Outfits: EndpointResponse, + Pets: EndpointResponse, + Professions: EndpointResponse, + Pvp: EndpointResponse, + Quaggans: EndpointResponse, + Questions: EndpointResponse, + Quests: EndpointResponse, + Races: EndpointResponse, + Raids: EndpointResponse, + Recipes: EndpointResponse, + Skills: EndpointResponse, + Skins: EndpointResponse, + Specializations: EndpointResponse, + Stories: EndpointResponse, + Titles: EndpointResponse, + Tokeninfo: EndpointResponse, + Traits: EndpointResponse, + Worldbosses: EndpointResponse, + Worlds: EndpointResponse, + Wvw: EndpointResponse, +} + + diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts new file mode 100644 index 0000000..3565e06 --- /dev/null +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -0,0 +1,44 @@ +import { Achievement, BaseCategory, BaseDaily, Group, Product } from "./responses/achievements" +import { Schema as BaseSchema } from './schema' + +export namespace Schema_1970_01_01 { + export interface Daily extends BaseDaily { + required_access: Product[] + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ + export interface Dailies { + pve: Daily[], + wvw: Daily[], + fractals: Daily[], + special: Daily[] + } + + export interface Category extends BaseCategory { + id: number, + name: string, + description: string, + order: number, + icon: string, + achievements: number[], + } + + export interface Cat { + id: number, + hint: string + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/build} */ + export interface Build { + id: number + } +} + +export interface Schema extends BaseSchema { + Achievement: Achievement, + Group: Group, + Daily: BaseDaily, + Dailies: Schema_1970_01_01.Dailies, + Category: Schema_1970_01_01.Category, + Dungeons: Dungeon +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_02_21.ts b/src/endpoints/schemas/schema_2019_02_21.ts new file mode 100644 index 0000000..e35a2ed --- /dev/null +++ b/src/endpoints/schemas/schema_2019_02_21.ts @@ -0,0 +1,5 @@ +export * from './schema_1970_01_01' + +export namespace Schema_2019_02_21 { + // TODO +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_03_22.ts b/src/endpoints/schemas/schema_2019_03_22.ts new file mode 100644 index 0000000..22b75eb --- /dev/null +++ b/src/endpoints/schemas/schema_2019_03_22.ts @@ -0,0 +1,5 @@ +export * from './schema_2019_02_21' + +export namespace Schema_2019_03_22 { + export type Cat = number +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_05_16.ts b/src/endpoints/schemas/schema_2019_05_16.ts new file mode 100644 index 0000000..8e6b2f0 --- /dev/null +++ b/src/endpoints/schemas/schema_2019_05_16.ts @@ -0,0 +1,17 @@ +import { BaseDaily, RequiredAccess } from "./responses/achievements" + +export * from './schema_2019_03_22' + +export namespace Schema_2019_05_16 { + export interface Daily extends BaseDaily { + required_access?: RequiredAccess + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ + export interface Dailies { + pve: Daily[], + wvw: Daily[], + fractals: Daily[], + special: Daily[] + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_05_21.ts b/src/endpoints/schemas/schema_2019_05_21.ts new file mode 100644 index 0000000..27b5cc8 --- /dev/null +++ b/src/endpoints/schemas/schema_2019_05_21.ts @@ -0,0 +1,5 @@ +export * from './schema_2019_05_16' + +export namespace Schema_2019_05_21 { + // TODO +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_05_22.ts b/src/endpoints/schemas/schema_2019_05_22.ts new file mode 100644 index 0000000..a5a6923 --- /dev/null +++ b/src/endpoints/schemas/schema_2019_05_22.ts @@ -0,0 +1,5 @@ +export * from './schema_2019_05_21' + +export namespace Schema_2019_05_22 { + // TODO +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_12_19.ts b/src/endpoints/schemas/schema_2019_12_19.ts new file mode 100644 index 0000000..6f766c0 --- /dev/null +++ b/src/endpoints/schemas/schema_2019_12_19.ts @@ -0,0 +1,5 @@ +export * from './schema_2019_05_22' + +export namespace Schema_2019_12_19 { + // TODO +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2020_11_17.ts b/src/endpoints/schemas/schema_2020_11_17.ts new file mode 100644 index 0000000..0b353fc --- /dev/null +++ b/src/endpoints/schemas/schema_2020_11_17.ts @@ -0,0 +1,5 @@ +export * from './schema_2019_12_19' + +export namespace Schema_2020_11_17 { + // TODO +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2021_04_06.ts b/src/endpoints/schemas/schema_2021_04_06.ts new file mode 100644 index 0000000..40a3549 --- /dev/null +++ b/src/endpoints/schemas/schema_2021_04_06.ts @@ -0,0 +1,5 @@ +export * from './schema_2020_11_17' + +export namespace Schema_2021_04_06 { + // TODO +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2021_07_15.ts b/src/endpoints/schemas/schema_2021_07_15.ts new file mode 100644 index 0000000..d0a58f3 --- /dev/null +++ b/src/endpoints/schemas/schema_2021_07_15.ts @@ -0,0 +1,5 @@ +export * from './schema_2021_04_06' + +export namespace Schema_2021_07_15 { + // TODO +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2022_03_09.ts b/src/endpoints/schemas/schema_2022_03_09.ts new file mode 100644 index 0000000..7ec04ca --- /dev/null +++ b/src/endpoints/schemas/schema_2022_03_09.ts @@ -0,0 +1,5 @@ +export * from './schema_2021_07_15' + +export namespace Schema_2022_03_09 { + // TODO +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2022_03_23.ts b/src/endpoints/schemas/schema_2022_03_23.ts new file mode 100644 index 0000000..3a7f861 --- /dev/null +++ b/src/endpoints/schemas/schema_2022_03_23.ts @@ -0,0 +1,28 @@ +import { BaseCategory, Flag, LevelTuple, RequiredAccess } from "./responses/achievements" + +export * from './schema_2022_03_09' + +export namespace Schema_2022_03_23 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/categories} */ + export interface Category extends BaseCategory { + achievements: [ + id: number, + name: string, + description: string, + order: number, + icon: string, + achievements: { + id: number, + required_access: RequiredAccess + flags: Flag[], + level: [number, number] + }, + tomorrow: { + id: number, + required_access: RequiredAccess, + flags: Flag[], + level: LevelTuple + } + ] + } +} diff --git a/src/types.ts b/src/types.ts index 77c0358..45ae6ee 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,6 +2,7 @@ export type ItemID = number export type URL = string +export type Language = 'en' | 'de' | 'es' | 'fr' export type Race = 'Human' | 'Norn' | 'Charr' | 'Sylvari' | 'Asura' export type Profession = 'Guardian' | 'Revenant' | 'Warrior' | 'Engineer' | 'Ranger' | 'Thief' | 'Elementalist' | 'Mesmer' | 'Necromancer' export type Region = 'Tyria' | 'Maguuma' | 'Desert' | 'Tundra' \ No newline at end of file From cac10eb5236b8784e1bdba4bebf224bb7469f6d6 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Wed, 3 May 2023 18:23:08 +0200 Subject: [PATCH 18/72] Change chaining result type to this --- src/endpoint.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/endpoint.ts b/src/endpoint.ts index 9145ecd..9c4b36f 100644 --- a/src/endpoint.ts +++ b/src/endpoint.ts @@ -53,7 +53,7 @@ export class AbstractEndpoint { // Set the schema version // FIXME: Type - public schema (schema): AbstractEndpoint { + public schema (schema): this { this.schemaVersion = schema this.debugMessage(`set the schema to ${schema}`) return this @@ -65,7 +65,7 @@ export class AbstractEndpoint { } // Set the language for locale-aware endpoints - public language (lang: Language): AbstractEndpoint { + public language (lang: Language): this { this.lang = lang this.debugMessage(`set the language to ${lang}`) return this @@ -73,7 +73,7 @@ export class AbstractEndpoint { // Set the api key for authenticated endpoints // FIXME: type - public authenticate (apiKey): AbstractEndpoint { + public authenticate (apiKey): this { this.apiKey = apiKey this.debugMessage(`set the api key to ${apiKey}`) return this @@ -81,7 +81,7 @@ export class AbstractEndpoint { // Set the debugging flag // FIXME: enum - public debugging (flag): AbstractEndpoint { + public debugging (flag): this { this.debug = flag return this } @@ -94,7 +94,7 @@ export class AbstractEndpoint { } // Skip caching and get the live data - public live (): AbstractEndpoint { + public live (): this { this._skipCache = true this.debugMessage(`skipping cache`) return this From 6f2816c61b7514af6d9ecf010b3eef034f8ca4bb Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Wed, 3 May 2023 19:17:27 +0200 Subject: [PATCH 19/72] Pivot type distribution --- .../schemas/responses/achievements.ts | 106 ++++++++++++++---- src/endpoints/schemas/responses/backstory.ts | 16 +-- src/endpoints/schemas/responses/build copy.ts | 3 + src/endpoints/schemas/responses/build.ts | 6 + src/endpoints/schemas/responses/cats.ts | 10 ++ src/endpoints/schemas/responses/dailies.ts | 13 +++ src/endpoints/schemas/responses/dungeons.ts | 12 +- src/endpoints/schemas/responses/gliders.ts | 19 ++++ src/endpoints/schemas/schema_1970_01_01.ts | 62 +++++----- src/endpoints/schemas/schema_2022_03_23.ts | 23 +--- 10 files changed, 179 insertions(+), 91 deletions(-) create mode 100644 src/endpoints/schemas/responses/build copy.ts create mode 100644 src/endpoints/schemas/responses/build.ts create mode 100644 src/endpoints/schemas/responses/cats.ts create mode 100644 src/endpoints/schemas/responses/dailies.ts create mode 100644 src/endpoints/schemas/responses/gliders.ts diff --git a/src/endpoints/schemas/responses/achievements.ts b/src/endpoints/schemas/responses/achievements.ts index f034567..d278bab 100644 --- a/src/endpoints/schemas/responses/achievements.ts +++ b/src/endpoints/schemas/responses/achievements.ts @@ -6,30 +6,96 @@ export type LevelObj = { min: number, max: number } export type RequiredAccess = { product: Product, condition: Condition } /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily} */ -export interface BaseDaily { +interface BaseDaily { id: number, level: LevelObj, } /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/categories} */ -export interface BaseCategory {} - -/** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/groups} */ -export interface Group { - id: string, - name: string, - description: string, - order: number, - categories: number[] +interface BaseCategory {} + + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/account/achievements} */ + export interface Achievement { + id: number, + bits?: number, + current?: number, + max?: number, + done: boolean, + repeated?: number, + unlocked?: number + } + + + export interface Daily extends BaseDaily { + required_access: Product[] + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ + export interface Dailies { + pve: Daily[], + wvw: Daily[], + fractals: Daily[], + special: Daily[] + } + + export interface Category extends BaseCategory { + id: number, + name: string, + description: string, + order: number, + icon: string, + achievements: number[], + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/groups} */ + export interface Group { + id: string, + name: string, + description: string, + order: number, + categories: number[] + } } - -/** {@link https://wiki.guildwars2.com/wiki/API:2/account/achievements} */ -export interface Achievement { - id: number, - bits?: number, - current?: number, - max?: number, - done: boolean, - repeated?: number, - unlocked?: number + + +export namespace Schema_2019_05_16 { + export interface Daily extends BaseDaily { + required_access?: RequiredAccess + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ + export interface Dailies { + pve: Daily[], + wvw: Daily[], + fractals: Daily[], + special: Daily[] + } } + + +export namespace Schema_2022_03_23 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/categories} */ + export interface Category extends BaseCategory { + achievements: [ + id: number, + name: string, + description: string, + order: number, + icon: string, + achievements: { + id: number, + required_access: RequiredAccess + flags: Flag[], + level: [number, number] + }, + tomorrow: { + id: number, + required_access: RequiredAccess, + flags: Flag[], + level: LevelTuple + } + ] + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/responses/backstory.ts b/src/endpoints/schemas/responses/backstory.ts index bbb209c..780edf6 100644 --- a/src/endpoints/schemas/responses/backstory.ts +++ b/src/endpoints/schemas/responses/backstory.ts @@ -1,12 +1,13 @@ import { Profession, Race } from "../../../types" -/** {@link https://wiki.guildwars2.com/wiki/API:2/characters/:id/backstory} */ -interface Backstory { +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/characters/:id/backstory} */ + export interface Backstory { backstory: string[] } - + /** {@link https://wiki.guildwars2.com/wiki/API:2/backstory/answers} */ - interface Answer { + export interface Answer { id: string, title: string, description: string, @@ -15,9 +16,9 @@ interface Backstory { professions: Profession[], races: Race[], } - + /** {@link https://wiki.guildwars2.com/wiki/API:2/backstory/questions} */ - interface Question { + export interface Question { id: number, title: string, description: string, @@ -25,4 +26,5 @@ interface Backstory { order: number, races: Race[], professions: Profession[] - } \ No newline at end of file + } +} diff --git a/src/endpoints/schemas/responses/build copy.ts b/src/endpoints/schemas/responses/build copy.ts new file mode 100644 index 0000000..3aca62d --- /dev/null +++ b/src/endpoints/schemas/responses/build copy.ts @@ -0,0 +1,3 @@ +export namespace Schema_1970_01_01 { + +} diff --git a/src/endpoints/schemas/responses/build.ts b/src/endpoints/schemas/responses/build.ts new file mode 100644 index 0000000..b63f4bb --- /dev/null +++ b/src/endpoints/schemas/responses/build.ts @@ -0,0 +1,6 @@ +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/build} */ + export interface Build { + id: number + } +} diff --git a/src/endpoints/schemas/responses/cats.ts b/src/endpoints/schemas/responses/cats.ts new file mode 100644 index 0000000..ee3362c --- /dev/null +++ b/src/endpoints/schemas/responses/cats.ts @@ -0,0 +1,10 @@ +export namespace Schema_1970_01_01 { + export interface Cat { + id: number, + hint: string + } +} + +export namespace Schema_2019_03_22 { + export type Cat = number +} \ No newline at end of file diff --git a/src/endpoints/schemas/responses/dailies.ts b/src/endpoints/schemas/responses/dailies.ts new file mode 100644 index 0000000..0bf7534 --- /dev/null +++ b/src/endpoints/schemas/responses/dailies.ts @@ -0,0 +1,13 @@ +export namespace Schema_1970_01_01 { + export interface Daily extends BaseDaily { + required_access: Product[] + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ + export interface Dailies { + pve: Daily[], + wvw: Daily[], + fractals: Daily[], + special: Daily[] + } +} diff --git a/src/endpoints/schemas/responses/dungeons.ts b/src/endpoints/schemas/responses/dungeons.ts index a29a349..7551048 100644 --- a/src/endpoints/schemas/responses/dungeons.ts +++ b/src/endpoints/schemas/responses/dungeons.ts @@ -1,7 +1,9 @@ -interface Dungeon { - id: string, - paths: { - id: string, - type: 'Story' | 'Explorable' +export namespace Schema_1970_01_01 { + export interface Dungeon { + id: string, + paths: { + id: string, + type: 'Story' | 'Explorable' + } } } \ No newline at end of file diff --git a/src/endpoints/schemas/responses/gliders.ts b/src/endpoints/schemas/responses/gliders.ts new file mode 100644 index 0000000..041e49e --- /dev/null +++ b/src/endpoints/schemas/responses/gliders.ts @@ -0,0 +1,19 @@ +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/gliders} */ + export interface Glider { + /** The id of the glider */ + id: number, + /** An array of item ids used to unlock the glider. Can be resolved against v2/items */ + unlock_items?: number[], + /** The order in which the glider appears in a list. This value is not unique. */ + order: number, + /** The icon uri for the glider. */ + icon: string, + /** The name of the glider as it appears in-game. */ + name: string, + /** The in-game glider description. */ + description: string, + /** List of dye ids. Can be resolved against v2/colors. */ + default_dies: number[] + } +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 3565e06..e098573 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -1,44 +1,32 @@ -import { Achievement, BaseCategory, BaseDaily, Group, Product } from "./responses/achievements" import { Schema as BaseSchema } from './schema' -export namespace Schema_1970_01_01 { - export interface Daily extends BaseDaily { - required_access: Product[] - } +import * as backstory from './responses/backstory' +import * as achievements from './responses/achievements' +import * as build from './responses/build' +import * as cats from './responses/cats' +import * as dungeons from './responses/dungeons' +import * as gliders from './responses/gliders' - /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ - export interface Dailies { - pve: Daily[], - wvw: Daily[], - fractals: Daily[], - special: Daily[] - } +export interface Schema extends BaseSchema { + // Achievements + Daily: achievements.Schema_1970_01_01.Daily + Dailies: achievements.Schema_1970_01_01.Dailies + Category: achievements.Schema_1970_01_01.Category + Achievement: achievements.Schema_1970_01_01.Achievement + Group: achievements.Schema_1970_01_01.Group - export interface Category extends BaseCategory { - id: number, - name: string, - description: string, - order: number, - icon: string, - achievements: number[], - } + // Build + Build: build.Schema_1970_01_01.Build + // Cats + Cats: cats.Schema_1970_01_01.Cat - export interface Cat { - id: number, - hint: string - } + // Backstory + Answers: backstory.Schema_1970_01_01.Answer + Questions: backstory.Schema_1970_01_01.Question - /** {@link https://wiki.guildwars2.com/wiki/API:2/build} */ - export interface Build { - id: number - } -} + // Dungeon + Dungeons: dungeons.Schema_1970_01_01.Dungeon -export interface Schema extends BaseSchema { - Achievement: Achievement, - Group: Group, - Daily: BaseDaily, - Dailies: Schema_1970_01_01.Dailies, - Category: Schema_1970_01_01.Category, - Dungeons: Dungeon -} \ No newline at end of file + // Gliders + Gliders: gliders.Schema_1970_01_01.Glider +} diff --git a/src/endpoints/schemas/schema_2022_03_23.ts b/src/endpoints/schemas/schema_2022_03_23.ts index 3a7f861..578ab12 100644 --- a/src/endpoints/schemas/schema_2022_03_23.ts +++ b/src/endpoints/schemas/schema_2022_03_23.ts @@ -3,26 +3,5 @@ import { BaseCategory, Flag, LevelTuple, RequiredAccess } from "./responses/achi export * from './schema_2022_03_09' export namespace Schema_2022_03_23 { - /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/categories} */ - export interface Category extends BaseCategory { - achievements: [ - id: number, - name: string, - description: string, - order: number, - icon: string, - achievements: { - id: number, - required_access: RequiredAccess - flags: Flag[], - level: [number, number] - }, - tomorrow: { - id: number, - required_access: RequiredAccess, - flags: Flag[], - level: LevelTuple - } - ] - } + // TODO } From 1374de0e34d210513c7f5d3e03511885c184ce34 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Wed, 3 May 2023 19:41:27 +0200 Subject: [PATCH 20/72] Move all exports from schema_1970_* to their respective namespaces --- src/endpoints/schemas/responses/continents.ts | 165 +++++++++--------- src/endpoints/schemas/schema_1970_01_01.ts | 4 + src/endpoints/schemas/schema_2019_05_16.ts | 11 +- src/endpoints/schemas/schema_2022_03_23.ts | 1 - 4 files changed, 88 insertions(+), 93 deletions(-) diff --git a/src/endpoints/schemas/responses/continents.ts b/src/endpoints/schemas/responses/continents.ts index 6e90984..a4d57fb 100644 --- a/src/endpoints/schemas/responses/continents.ts +++ b/src/endpoints/schemas/responses/continents.ts @@ -1,94 +1,95 @@ -type FloorID = number -type Dim = [number, number] -type Coordinate = [number, number] -type Rectangle = [Dim, Dim] +export namespace Schema_1970_01_01 { + type Dim = [number, number] + type Coordinate = [number, number] + type Rectangle = [Dim, Dim] -interface Continent { - id: number, - name: 'Tyria' | 'Mists', - continent_dims: Dim, - min_zoom: number, - max_zoom: number, - floors: number[] -} + export interface Continent { + id: number, + name: 'Tyria' | 'Mists', + continent_dims: Dim, + min_zoom: number, + max_zoom: number, + floors: number[] + } -interface Floor { - texture_dims: Dim, - clamped_view: Rectangle, - regions: { [key: number]: Region } -} + export interface Floor { + texture_dims: Dim, + clamped_view: Rectangle, + regions: { [key: number]: Region } + } -interface Region { - name: string, - label_coord: Coordinate, - continent_rect: Rectangle, - maps: { [key: number]: MapInfo } -} + export interface Region { + name: string, + label_coord: Coordinate, + continent_rect: Rectangle, + maps: { [key: number]: MapInfo } + } -interface MapInfo { - name: string, - min_level: number, - max_level: number, - default_floor: number, - label_coord: Coordinate, - map_rect: Rectangle, - continent_rect: Rectangle, - points_of_interest: PointOfInterest[], - tasks: Task[], - skill_challenges: SkillChallenge[], - sectors: Sector[], - adventures: Adventure[], - mastery_points: MasteryPoint[] -} + export interface MapInfo { + name: string, + min_level: number, + max_level: number, + default_floor: number, + label_coord: Coordinate, + map_rect: Rectangle, + continent_rect: Rectangle, + points_of_interest: PointOfInterest[], + tasks: Task[], + skill_challenges: SkillChallenge[], + sectors: Sector[], + adventures: Adventure[], + mastery_points: MasteryPoint[] + } -interface Task { - objective: string, - level: number, - coord: Coordinate, - bounds: Coordinate[], - id: number, - chat_link: string -} + export interface Task { + objective: string, + level: number, + coord: Coordinate, + bounds: Coordinate[], + id: number, + chat_link: string + } -interface SkillChallenge { - coord: Coordinate, - id: string -} + export interface SkillChallenge { + coord: Coordinate, + id: string + } -interface Sector { - name: string, - level: number, - coord: Coordinate, - bounds: Coordinate[], - chat_link: String, - id: number -} + export interface Sector { + name: string, + level: number, + coord: Coordinate, + bounds: Coordinate[], + chat_link: String, + id: number + } -interface Adventure { - coord: Coordinate, - id: string, - name: string, - description: string -} + export interface Adventure { + coord: Coordinate, + id: string, + name: string, + description: string + } -interface MasteryPoint { - coord: Coordinate, - id: number, - region: Region, + export interface MasteryPoint { + coord: Coordinate, + id: number, + region: Region, -} + } -interface PoI { - name: string, - type: T, - floor: number, - coord: Dim, - id: number, - chat_link: string -} + export interface PoI { + name: string, + type: T, + floor: number, + coord: Dim, + id: number, + chat_link: string + } -interface Landmark extends PoI<'landmark'> {} -interface Waypoint extends PoI<'waypoint'> {} -interface Vista extends PoI<'vista'> {} -interface Unlock extends PoI<'unlock'> { chat_link: string } -type PointOfInterest = Landmark | Waypoint | Vista | Unlock \ No newline at end of file + export interface Landmark extends PoI<'landmark'> {} + export interface Waypoint extends PoI<'waypoint'> {} + export interface Vista extends PoI<'vista'> {} + export interface Unlock extends PoI<'unlock'> { chat_link: string } + export type PointOfInterest = Landmark | Waypoint | Vista | Unlock +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index e098573..7a3e897 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -6,6 +6,7 @@ import * as build from './responses/build' import * as cats from './responses/cats' import * as dungeons from './responses/dungeons' import * as gliders from './responses/gliders' +import * as continents from './responses/continents' export interface Schema extends BaseSchema { // Achievements @@ -29,4 +30,7 @@ export interface Schema extends BaseSchema { // Gliders Gliders: gliders.Schema_1970_01_01.Glider + + // Continents + Continents: continents.Schema_1970_01_01.Continent } diff --git a/src/endpoints/schemas/schema_2019_05_16.ts b/src/endpoints/schemas/schema_2019_05_16.ts index 8e6b2f0..3ddc2bc 100644 --- a/src/endpoints/schemas/schema_2019_05_16.ts +++ b/src/endpoints/schemas/schema_2019_05_16.ts @@ -3,15 +3,6 @@ import { BaseDaily, RequiredAccess } from "./responses/achievements" export * from './schema_2019_03_22' export namespace Schema_2019_05_16 { - export interface Daily extends BaseDaily { - required_access?: RequiredAccess - } + // daily - /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ - export interface Dailies { - pve: Daily[], - wvw: Daily[], - fractals: Daily[], - special: Daily[] - } } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2022_03_23.ts b/src/endpoints/schemas/schema_2022_03_23.ts index 578ab12..18d45e8 100644 --- a/src/endpoints/schemas/schema_2022_03_23.ts +++ b/src/endpoints/schemas/schema_2022_03_23.ts @@ -1,4 +1,3 @@ -import { BaseCategory, Flag, LevelTuple, RequiredAccess } from "./responses/achievements" export * from './schema_2022_03_09' From 96d09bb4b294bff97baf7030ba74d9c5821596e4 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Wed, 3 May 2023 19:47:39 +0200 Subject: [PATCH 21/72] Add some documentation and add dailycrafting --- src/endpoints/schemas/responses/cats.ts | 2 + src/endpoints/schemas/responses/colors.ts | 49 ++++++++++--------- src/endpoints/schemas/responses/dailies.ts | 13 ----- .../schemas/responses/dailycrafting.ts | 6 ++- src/endpoints/schemas/schema_1970_01_01.ts | 8 +++ 5 files changed, 41 insertions(+), 37 deletions(-) delete mode 100644 src/endpoints/schemas/responses/dailies.ts diff --git a/src/endpoints/schemas/responses/cats.ts b/src/endpoints/schemas/responses/cats.ts index ee3362c..44855f6 100644 --- a/src/endpoints/schemas/responses/cats.ts +++ b/src/endpoints/schemas/responses/cats.ts @@ -1,4 +1,5 @@ export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/account/home/cats} */ export interface Cat { id: number, hint: string @@ -6,5 +7,6 @@ export namespace Schema_1970_01_01 { } export namespace Schema_2019_03_22 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/account/home/cats} */ export type Cat = number } \ No newline at end of file diff --git a/src/endpoints/schemas/responses/colors.ts b/src/endpoints/schemas/responses/colors.ts index 158b163..f53d92a 100644 --- a/src/endpoints/schemas/responses/colors.ts +++ b/src/endpoints/schemas/responses/colors.ts @@ -1,26 +1,29 @@ -export type RGB = [number, number, number] -export type Hue = 'Gray' | 'Brown' | 'Red' | 'Orange' | 'Yellow' | 'Green' | 'Blue' | 'Purple' -export type Material = 'Vibrant' | 'Leather' | 'Metal' -export type Rarity = 'Start' | 'Common' | 'Uncommon' | 'Rare' | 'Purple' -export type Category = Hue | Material | Rarity +export namespace Schema_1970_01_01 { + type RGB = [number, number, number] + type Hue = 'Gray' | 'Brown' | 'Red' | 'Orange' | 'Yellow' | 'Green' | 'Blue' | 'Purple' + type Material = 'Vibrant' | 'Leather' | 'Metal' + type Rarity = 'Start' | 'Common' | 'Uncommon' | 'Rare' | 'Purple' + type Category = Hue | Material | Rarity -export interface Details { - brightness: number, - contrast: number, - hue: number, - saturation: number, - lightness: number, - rgb: RGB -} + interface Details { + brightness: number, + contrast: number, + hue: number, + saturation: number, + lightness: number, + rgb: RGB + } -export interface Color { - id: number, - name: string, - base_rgb: RGB, - cloth: Details, - leather: Details, - metal: Details, - fur?: Details, - item?: number - categories: Category[] + /** {@link https://wiki.guildwars2.com/wiki/API:2/colors} */ + export interface Color { + id: number, + name: string, + base_rgb: RGB, + cloth: Details, + leather: Details, + metal: Details, + fur?: Details, + item?: number + categories: Category[] + } } \ No newline at end of file diff --git a/src/endpoints/schemas/responses/dailies.ts b/src/endpoints/schemas/responses/dailies.ts deleted file mode 100644 index 0bf7534..0000000 --- a/src/endpoints/schemas/responses/dailies.ts +++ /dev/null @@ -1,13 +0,0 @@ -export namespace Schema_1970_01_01 { - export interface Daily extends BaseDaily { - required_access: Product[] - } - - /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ - export interface Dailies { - pve: Daily[], - wvw: Daily[], - fractals: Daily[], - special: Daily[] - } -} diff --git a/src/endpoints/schemas/responses/dailycrafting.ts b/src/endpoints/schemas/responses/dailycrafting.ts index 893f07d..b606288 100644 --- a/src/endpoints/schemas/responses/dailycrafting.ts +++ b/src/endpoints/schemas/responses/dailycrafting.ts @@ -1 +1,5 @@ -type DailyCrafting = 'lump_of_mithrilium' | 'spool_of_silk_weaving_thread' | 'spool_of_thick_elonian_cord' \ No newline at end of file +export namespace Schema_1970_01_01 { + type DailyCraftingItem = 'lump_of_mithrilium' | 'spool_of_silk_weaving_thread' | 'spool_of_thick_elonian_cord' + + export type DailyCrafting = DailyCraftingItem[] +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 7a3e897..1bf4561 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -7,6 +7,8 @@ import * as cats from './responses/cats' import * as dungeons from './responses/dungeons' import * as gliders from './responses/gliders' import * as continents from './responses/continents' +import * as colors from './responses/colors' +import * as dailycrafting from './responses/dailycrafting' export interface Schema extends BaseSchema { // Achievements @@ -25,6 +27,12 @@ export interface Schema extends BaseSchema { Answers: backstory.Schema_1970_01_01.Answer Questions: backstory.Schema_1970_01_01.Question + // Colors + Colors: colors.Schema_1970_01_01.Color + + // Dailycrafting + Dailycrafting: dailycrafting.Schema_1970_01_01.DailyCrafting + // Dungeon Dungeons: dungeons.Schema_1970_01_01.Dungeon From d5fd148ace67d3a2e9e90d89a818e721166c4e86 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Wed, 3 May 2023 19:50:50 +0200 Subject: [PATCH 22/72] Make dungeon types more solid --- src/endpoints/schemas/responses/dungeons.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/endpoints/schemas/responses/dungeons.ts b/src/endpoints/schemas/responses/dungeons.ts index 7551048..34cfba8 100644 --- a/src/endpoints/schemas/responses/dungeons.ts +++ b/src/endpoints/schemas/responses/dungeons.ts @@ -1,6 +1,7 @@ export namespace Schema_1970_01_01 { + type Dungeons = 'ascalonian_catacombs' | 'caudecus_manor' | 'twilight_arbor' | 'sorrows_embrace' | 'citadel_of_flame' | 'honor_of_the_waves' | 'crucible_of_eternity' | 'ruined_city_of_arah' export interface Dungeon { - id: string, + id: Dungeons, paths: { id: string, type: 'Story' | 'Explorable' From 9f3cd4b797cdbdf245e149170133b7dd02db2a14 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Wed, 3 May 2023 19:55:27 +0200 Subject: [PATCH 23/72] Add currencies endpoint response --- src/endpoints/schemas/responses/build copy.ts | 3 --- src/endpoints/schemas/responses/currencies.ts | 15 +++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 6 +++++- 3 files changed, 20 insertions(+), 4 deletions(-) delete mode 100644 src/endpoints/schemas/responses/build copy.ts create mode 100644 src/endpoints/schemas/responses/currencies.ts diff --git a/src/endpoints/schemas/responses/build copy.ts b/src/endpoints/schemas/responses/build copy.ts deleted file mode 100644 index 3aca62d..0000000 --- a/src/endpoints/schemas/responses/build copy.ts +++ /dev/null @@ -1,3 +0,0 @@ -export namespace Schema_1970_01_01 { - -} diff --git a/src/endpoints/schemas/responses/currencies.ts b/src/endpoints/schemas/responses/currencies.ts new file mode 100644 index 0000000..164955e --- /dev/null +++ b/src/endpoints/schemas/responses/currencies.ts @@ -0,0 +1,15 @@ +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/currencies} */ + export interface Currency { + /** The currency's ID. **/ + id: number + /** The currency's name. **/ + name: string + /** A description of the currency. */ + description: string + /** A URL to an icon for the currency. */ + icon: string + /** A number that can be used to sort the list of currencies when ordered from least to greatest. */ + order: number + } +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 1bf4561..c5b8f2f 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -4,6 +4,7 @@ import * as backstory from './responses/backstory' import * as achievements from './responses/achievements' import * as build from './responses/build' import * as cats from './responses/cats' +import * as currencies from './responses/currencies' import * as dungeons from './responses/dungeons' import * as gliders from './responses/gliders' import * as continents from './responses/continents' @@ -25,7 +26,10 @@ export interface Schema extends BaseSchema { // Backstory Answers: backstory.Schema_1970_01_01.Answer - Questions: backstory.Schema_1970_01_01.Question + Questions: backstory.Schema_1970_01_01.Question + + // Currencies + Currencies: currencies.Schema_1970_01_01.Currency // Colors Colors: colors.Schema_1970_01_01.Color From f687e7560908c253b0e5bbb0a9ae800f264693e2 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Wed, 3 May 2023 20:18:12 +0200 Subject: [PATCH 24/72] Quickfix some compilation errors for review --- src/endpoint.ts | 3 ++- src/endpoints/schemas/schema_2022_03_09.ts | 7 +++++-- src/endpoints/wvw.ts | 5 +++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/endpoint.ts b/src/endpoint.ts index 9c4b36f..777bb85 100644 --- a/src/endpoint.ts +++ b/src/endpoint.ts @@ -19,7 +19,8 @@ interface IDable { id: number } -export class AbstractEndpoint { +// FIXME: remove any! Just to make compilation go through for now +export class AbstractEndpoint { public client protected schemaVersion: string protected lang: Language diff --git a/src/endpoints/schemas/schema_2022_03_09.ts b/src/endpoints/schemas/schema_2022_03_09.ts index 7ec04ca..63a5f89 100644 --- a/src/endpoints/schemas/schema_2022_03_09.ts +++ b/src/endpoints/schemas/schema_2022_03_09.ts @@ -1,5 +1,8 @@ export * from './schema_2021_07_15' +import { Schema as BaseSchema } from './schema' +import * as cats from './responses/cats' -export namespace Schema_2022_03_09 { - // TODO +export interface Schema extends BaseSchema { + Cats: cats.Schema_2019_03_22.Cat + // TODO: add all the other exports } \ No newline at end of file diff --git a/src/endpoints/wvw.ts b/src/endpoints/wvw.ts index 78467f8..6f421ee 100644 --- a/src/endpoints/wvw.ts +++ b/src/endpoints/wvw.ts @@ -1,4 +1,5 @@ import { AbstractEndpoint } from '../endpoint' +import { Schema } from './schemas/schema' type Team = 'red' | 'blue' | 'green' type Top = 'kills' | 'kdr' @@ -158,7 +159,7 @@ class TopStatsEndpoint extends AbstractEndpoint { } } -class MatchesOverviewEndpoint extends AbstractEndpoint { +class MatchesOverviewEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/wvw/matches/overview' @@ -168,7 +169,7 @@ class MatchesOverviewEndpoint extends AbstractEndpoint { } public world (worldId: WorldID): Promise { - return super.get(`?world=${worldId}`, true) + return super.get(`?world=${worldId}`, true) } } From b39edcb0f03e10e04b7ff5634bb8f410906d6775 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Wed, 3 May 2023 20:24:40 +0200 Subject: [PATCH 25/72] Fix some compile errors --- src/client.ts | 3 ++- src/endpoints/account.ts | 2 +- src/endpoints/achievements.ts | 2 +- src/endpoints/characters.ts | 1 + src/endpoints/colors.ts | 2 +- src/endpoints/continents.ts | 3 ++- src/endpoints/schemas/schema_2019_05_16.ts | 2 -- src/endpoints/wvw.ts | 4 ++-- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/client.ts b/src/client.ts index 010656d..e593c7a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -226,7 +226,8 @@ export class Client { } pvp () { - return new endpoints.PvpEndpoint(this) + // FIXME: bug? No fromAccount argument was originally provided, so it always behaved falsey + return new endpoints.PvpEndpoint(this, false) } quaggans () { diff --git a/src/endpoints/account.ts b/src/endpoints/account.ts index 94b4b6e..0300bdd 100644 --- a/src/endpoints/account.ts +++ b/src/endpoints/account.ts @@ -6,7 +6,7 @@ const CommerceEndpoint = require('./commerce') const accountBlob = require('./account-blob.js') const resetTime = require('../helpers/resetTime') -export class AccountEndpoint extends AbstractEndpoint { +export class AccountEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/account' diff --git a/src/endpoints/achievements.ts b/src/endpoints/achievements.ts index 9e5a631..ec7bd06 100644 --- a/src/endpoints/achievements.ts +++ b/src/endpoints/achievements.ts @@ -96,7 +96,7 @@ interface Achievement { } -export class AchievementsEndpoint extends AbstractEndpoint { +export class AchievementsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/achievements' diff --git a/src/endpoints/characters.ts b/src/endpoints/characters.ts index f797f20..bb04b5d 100644 --- a/src/endpoints/characters.ts +++ b/src/endpoints/characters.ts @@ -1,4 +1,5 @@ import { AbstractEndpoint } from '../endpoint' +import { Schema } from './schemas/schema' export class CharactersEndpoint extends AbstractEndpoint { public name: string diff --git a/src/endpoints/colors.ts b/src/endpoints/colors.ts index b28e4e0..b6f93d1 100644 --- a/src/endpoints/colors.ts +++ b/src/endpoints/colors.ts @@ -1,7 +1,7 @@ import { AbstractEndpoint } from '../endpoint' import { Schema } from './schemas/schema' -export class ColorsEndpoint extends AbstractEndpoint { +export class ColorsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/colors' diff --git a/src/endpoints/continents.ts b/src/endpoints/continents.ts index daa8ab6..e11f9ef 100644 --- a/src/endpoints/continents.ts +++ b/src/endpoints/continents.ts @@ -1,6 +1,7 @@ import { AbstractEndpoint } from '../endpoint' +import { Schema } from './schemas/schema' -export class ContinentsEndpoint extends AbstractEndpoint { +export class ContinentsEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/continents' diff --git a/src/endpoints/schemas/schema_2019_05_16.ts b/src/endpoints/schemas/schema_2019_05_16.ts index 3ddc2bc..b8c3d9b 100644 --- a/src/endpoints/schemas/schema_2019_05_16.ts +++ b/src/endpoints/schemas/schema_2019_05_16.ts @@ -1,5 +1,3 @@ -import { BaseDaily, RequiredAccess } from "./responses/achievements" - export * from './schema_2019_03_22' export namespace Schema_2019_05_16 { diff --git a/src/endpoints/wvw.ts b/src/endpoints/wvw.ts index 6f421ee..649920e 100644 --- a/src/endpoints/wvw.ts +++ b/src/endpoints/wvw.ts @@ -116,8 +116,8 @@ class MatchesEndpoint extends AbstractEndpoint { this.cacheTime = 30 } - world (worldId: WorldID): World { - return super.get(`?world=${worldId}`, true) + world (worldId: WorldID): Promise { + return super.get(`?world=${worldId}`, true) } overview () { From eb3dae91d47ebb32cd89422d70d2887a6538eaf7 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Thu, 4 May 2023 06:55:03 +0200 Subject: [PATCH 26/72] Remove neccessity to re-declare every response via Omit --- src/endpoints/schemas/schema_2019_02_21.ts | 6 +++--- src/endpoints/schemas/schema_2019_03_22.ts | 7 ++++--- src/endpoints/schemas/schema_2019_05_16.ts | 5 ++--- src/endpoints/schemas/schema_2019_05_21.ts | 6 +++--- src/endpoints/schemas/schema_2019_05_22.ts | 6 +++--- src/endpoints/schemas/schema_2019_12_19.ts | 6 +++--- src/endpoints/schemas/schema_2020_11_17.ts | 6 +++--- src/endpoints/schemas/schema_2021_04_06.ts | 6 +++--- src/endpoints/schemas/schema_2021_07_15.ts | 6 +++--- src/endpoints/schemas/schema_2022_03_09.ts | 7 ++----- src/endpoints/schemas/schema_2022_03_23.ts | 7 +++---- 11 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/endpoints/schemas/schema_2019_02_21.ts b/src/endpoints/schemas/schema_2019_02_21.ts index e35a2ed..8403b07 100644 --- a/src/endpoints/schemas/schema_2019_02_21.ts +++ b/src/endpoints/schemas/schema_2019_02_21.ts @@ -1,5 +1,5 @@ -export * from './schema_1970_01_01' +import { Schema as BaseSchema } from './schema_1970_01_01' + +export interface Schema extends BaseSchema { -export namespace Schema_2019_02_21 { - // TODO } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_03_22.ts b/src/endpoints/schemas/schema_2019_03_22.ts index 22b75eb..5389d81 100644 --- a/src/endpoints/schemas/schema_2019_03_22.ts +++ b/src/endpoints/schemas/schema_2019_03_22.ts @@ -1,5 +1,6 @@ -export * from './schema_2019_02_21' +import { Schema as BaseSchema } from './schema_2019_02_21' +import * as cats from './responses/cats' -export namespace Schema_2019_03_22 { - export type Cat = number +export interface Schema extends Omit { + Cats: cats.Schema_2019_03_22.Cat } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_05_16.ts b/src/endpoints/schemas/schema_2019_05_16.ts index b8c3d9b..f95236e 100644 --- a/src/endpoints/schemas/schema_2019_05_16.ts +++ b/src/endpoints/schemas/schema_2019_05_16.ts @@ -1,6 +1,5 @@ -export * from './schema_2019_03_22' +import { Schema as BaseSchema } from './schema_2019_03_22' -export namespace Schema_2019_05_16 { - // daily +export interface Schema extends BaseSchema { } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_05_21.ts b/src/endpoints/schemas/schema_2019_05_21.ts index 27b5cc8..87ad94b 100644 --- a/src/endpoints/schemas/schema_2019_05_21.ts +++ b/src/endpoints/schemas/schema_2019_05_21.ts @@ -1,5 +1,5 @@ -export * from './schema_2019_05_16' +import { Schema as BaseSchema } from './schema_2019_05_16' + +export interface Schema extends BaseSchema { -export namespace Schema_2019_05_21 { - // TODO } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_05_22.ts b/src/endpoints/schemas/schema_2019_05_22.ts index a5a6923..813759d 100644 --- a/src/endpoints/schemas/schema_2019_05_22.ts +++ b/src/endpoints/schemas/schema_2019_05_22.ts @@ -1,5 +1,5 @@ -export * from './schema_2019_05_21' +import { Schema as BaseSchema } from './schema_2019_05_21' + +export interface Schema extends BaseSchema { -export namespace Schema_2019_05_22 { - // TODO } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_12_19.ts b/src/endpoints/schemas/schema_2019_12_19.ts index 6f766c0..ea80d79 100644 --- a/src/endpoints/schemas/schema_2019_12_19.ts +++ b/src/endpoints/schemas/schema_2019_12_19.ts @@ -1,5 +1,5 @@ -export * from './schema_2019_05_22' +import { Schema as BaseSchema } from './schema_2019_05_22' + +export interface Schema extends BaseSchema { -export namespace Schema_2019_12_19 { - // TODO } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2020_11_17.ts b/src/endpoints/schemas/schema_2020_11_17.ts index 0b353fc..3d073e6 100644 --- a/src/endpoints/schemas/schema_2020_11_17.ts +++ b/src/endpoints/schemas/schema_2020_11_17.ts @@ -1,5 +1,5 @@ -export * from './schema_2019_12_19' +import { Schema as BaseSchema } from './schema_2019_12_19' + +export interface Schema extends BaseSchema { -export namespace Schema_2020_11_17 { - // TODO } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2021_04_06.ts b/src/endpoints/schemas/schema_2021_04_06.ts index 40a3549..adc20c8 100644 --- a/src/endpoints/schemas/schema_2021_04_06.ts +++ b/src/endpoints/schemas/schema_2021_04_06.ts @@ -1,5 +1,5 @@ -export * from './schema_2020_11_17' +import { Schema as BaseSchema } from './schema_2020_11_17' + +export interface Schema extends BaseSchema { -export namespace Schema_2021_04_06 { - // TODO } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2021_07_15.ts b/src/endpoints/schemas/schema_2021_07_15.ts index d0a58f3..259abd6 100644 --- a/src/endpoints/schemas/schema_2021_07_15.ts +++ b/src/endpoints/schemas/schema_2021_07_15.ts @@ -1,5 +1,5 @@ -export * from './schema_2021_04_06' +import { Schema as BaseSchema } from './schema_2021_04_06' + +export interface Schema extends BaseSchema { -export namespace Schema_2021_07_15 { - // TODO } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2022_03_09.ts b/src/endpoints/schemas/schema_2022_03_09.ts index 63a5f89..b70263e 100644 --- a/src/endpoints/schemas/schema_2022_03_09.ts +++ b/src/endpoints/schemas/schema_2022_03_09.ts @@ -1,8 +1,5 @@ -export * from './schema_2021_07_15' -import { Schema as BaseSchema } from './schema' -import * as cats from './responses/cats' +import { Schema as BaseSchema } from './schema_2021_07_15' export interface Schema extends BaseSchema { - Cats: cats.Schema_2019_03_22.Cat - // TODO: add all the other exports + } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2022_03_23.ts b/src/endpoints/schemas/schema_2022_03_23.ts index 18d45e8..840fabb 100644 --- a/src/endpoints/schemas/schema_2022_03_23.ts +++ b/src/endpoints/schemas/schema_2022_03_23.ts @@ -1,6 +1,5 @@ +import { Schema as BaseSchema } from './schema_2022_03_09' -export * from './schema_2022_03_09' +export interface Schema extends BaseSchema { -export namespace Schema_2022_03_23 { - // TODO -} +} \ No newline at end of file From 2f8137360337e8bafe3d78b17ff74bb81305c8bf Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Thu, 4 May 2023 07:02:24 +0200 Subject: [PATCH 27/72] Add emblem response --- src/endpoints/schemas/responses/emblems.ts | 11 +++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 5 +++++ 2 files changed, 16 insertions(+) create mode 100644 src/endpoints/schemas/responses/emblems.ts diff --git a/src/endpoints/schemas/responses/emblems.ts b/src/endpoints/schemas/responses/emblems.ts new file mode 100644 index 0000000..11215a6 --- /dev/null +++ b/src/endpoints/schemas/responses/emblems.ts @@ -0,0 +1,11 @@ +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/emblem} */ + interface Layer { + /** The ID of the emblem part. */ + id: number, + /** An array of URLs to images that make up the various parts of the emblem. */ + layers: string[] + } + + export type Emblem = Layer[] +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index c5b8f2f..aeecb34 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -10,6 +10,7 @@ import * as gliders from './responses/gliders' import * as continents from './responses/continents' import * as colors from './responses/colors' import * as dailycrafting from './responses/dailycrafting' +import * as emblems from './responses/emblems' export interface Schema extends BaseSchema { // Achievements @@ -21,6 +22,7 @@ export interface Schema extends BaseSchema { // Build Build: build.Schema_1970_01_01.Build + // Cats Cats: cats.Schema_1970_01_01.Cat @@ -40,6 +42,9 @@ export interface Schema extends BaseSchema { // Dungeon Dungeons: dungeons.Schema_1970_01_01.Dungeon + // Emblem + Emblem: emblems.Schema_1970_01_01.Emblem + // Gliders Gliders: gliders.Schema_1970_01_01.Glider From 6926ad6c69b119a1829c465bd54b017f34f4a788 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Thu, 4 May 2023 07:05:16 +0200 Subject: [PATCH 28/72] Add titles response --- src/endpoints/schemas/responses/titles.ts | 15 +++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 4 ++++ 2 files changed, 19 insertions(+) create mode 100644 src/endpoints/schemas/responses/titles.ts diff --git a/src/endpoints/schemas/responses/titles.ts b/src/endpoints/schemas/responses/titles.ts new file mode 100644 index 0000000..97f964b --- /dev/null +++ b/src/endpoints/schemas/responses/titles.ts @@ -0,0 +1,15 @@ +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/build} */ + export interface Title { + /** The id of the title. */ + id: number + /** The name of the title (this is also the title displayed over a character in-game.) */ + name: string + /** (Now depreciated) - The id of the achievement that grants this title; resolvable against v2/achievements. */ + achievement: number + /** The id of the achievement that grants this title; resolvable against v2/achievements. */ + achievements: number[] + /** The amount of AP required to have said title. */ + ap_required: number + } +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index aeecb34..6761532 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -11,6 +11,7 @@ import * as continents from './responses/continents' import * as colors from './responses/colors' import * as dailycrafting from './responses/dailycrafting' import * as emblems from './responses/emblems' +import * as titles from './responses/titles' export interface Schema extends BaseSchema { // Achievements @@ -50,4 +51,7 @@ export interface Schema extends BaseSchema { // Continents Continents: continents.Schema_1970_01_01.Continent + + // Titles + Titles: titles.Schema_1970_01_01.Title } From 502f1734667d415e665c0db92ad861b27c0a47be Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Thu, 4 May 2023 07:40:41 +0200 Subject: [PATCH 29/72] Add titles and skins --- src/endpoints/schemas/responses/skins.ts | 66 ++++++++++++++++++++++ src/endpoints/schemas/responses/titles.ts | 2 +- src/endpoints/schemas/schema_1970_01_01.ts | 14 +---- src/types.ts | 3 +- 4 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 src/endpoints/schemas/responses/skins.ts diff --git a/src/endpoints/schemas/responses/skins.ts b/src/endpoints/schemas/responses/skins.ts new file mode 100644 index 0000000..8edcfb6 --- /dev/null +++ b/src/endpoints/schemas/responses/skins.ts @@ -0,0 +1,66 @@ +import { Race, Rarity, URL } from "../../../types" + +type WeightClass = 'Clothing' | 'Light' | 'Medium' | 'Heavy' +type SkinType = 'Armor' | 'Weapon' | 'Back' | 'Gathering' +type Flag = 'ShowInWardRobe' | 'NoCost' |'HideIfLocked' | 'OverrideRarity' +type Material = 'cloth' | 'leather' | 'metal' +type Overrides = 'AsuraMale' | 'AsuraFemale' | 'CharrMale' | 'CharrFemale' | 'HumanMale' | 'HumanFemale' | 'NornMale' | 'NornFemale' | 'SylvariMale' | 'SylvariFemale' +type DyeSlot = { + /** The id of the default color, to be resolved against v2/colors */ + color_id: number, + /** The type of material. Either cloth, leather, metal */ + material: Material +} + +interface Armor { + /** The armor type (slot). */ + type: string // FIXME: typedef? + /** The armor weight, either Clothing, Light, Medium or Heavy. */ + weight_class: WeightClass + /** An object containing information on default slots and skin overrides. If the array item is null, this means dye cannot be applied to that slot, except if otherwise overriden by non-null values in the overrides array. */ + dye_slots: { + default: DyeSlot[], + /** Object of race/gender overrides. Each sub-object follows the same structure as default. The possible override sub-objects are: AsuraMale, AsuraFemale, CharrMale, CharrFemale, HumanMale, HumanFemale, NornMale, NornFemale, SylvariMale, SylvariFemale */ + overrides: {[key in Overrides]?: DyeSlot[]} + } +} + +interface Weapon { + /** The weapon type. */ + type: string // FIXME: typedef? + /** The damage type, either Physical, Fire, Lightning, Ice or Choking. */ + damage_type: 'Physical' | 'Fire' | 'Lightning' | 'Ice' | 'Choking' +} + +/** The tool type, either Foraging, Logging or Mining */ +type GatheringTool = 'Foraging' | 'Logging' | 'Mining' + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/account/skins} */ + export interface Skin { + /** The skin id. */ + id: number + /** The name of the skin. */ + name: string + /** The skin type, either Armor, Weapon, Back or Gathering. */ + type: SkinType + /** Additional skin flags. Possible flags are: + * - ShowInWardrobe – When displayed in the account wardrobe (set for all skins listed in the API). + * - NoCost – When applying the skin is free. + * - HideIfLocked – When the skin is hidden until it is unlocked. + * - OverrideRarity - When the skin overrides item rarity when applied + */ + flags: Flag[] + /** Race restrictions that apply to the skin, e.g. Human will be a listed restriction, if the skin can only be applied to human characters. */ + restrictions: Race[] + /** The full icon URL. */ + icon: URL + /** The rarity of the skin */ + rarity: Rarity + /** Optional skin description. */ + description: string + /** Additional skin details if applicable, depending on the skin type */ + details: Armor | Weapon | GatheringTool + } + +} diff --git a/src/endpoints/schemas/responses/titles.ts b/src/endpoints/schemas/responses/titles.ts index 97f964b..518a415 100644 --- a/src/endpoints/schemas/responses/titles.ts +++ b/src/endpoints/schemas/responses/titles.ts @@ -1,5 +1,5 @@ export namespace Schema_1970_01_01 { - /** {@link https://wiki.guildwars2.com/wiki/API:2/build} */ + /** {@link https://wiki.guildwars2.com/wiki/API:2/titles} */ export interface Title { /** The id of the title. */ id: number diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 6761532..82d5cc4 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -11,6 +11,7 @@ import * as continents from './responses/continents' import * as colors from './responses/colors' import * as dailycrafting from './responses/dailycrafting' import * as emblems from './responses/emblems' +import * as skins from './responses/skins' import * as titles from './responses/titles' export interface Schema extends BaseSchema { @@ -20,38 +21,29 @@ export interface Schema extends BaseSchema { Category: achievements.Schema_1970_01_01.Category Achievement: achievements.Schema_1970_01_01.Achievement Group: achievements.Schema_1970_01_01.Group - // Build Build: build.Schema_1970_01_01.Build - // Cats Cats: cats.Schema_1970_01_01.Cat - // Backstory Answers: backstory.Schema_1970_01_01.Answer Questions: backstory.Schema_1970_01_01.Question - // Currencies Currencies: currencies.Schema_1970_01_01.Currency - // Colors Colors: colors.Schema_1970_01_01.Color - // Dailycrafting Dailycrafting: dailycrafting.Schema_1970_01_01.DailyCrafting - // Dungeon Dungeons: dungeons.Schema_1970_01_01.Dungeon - // Emblem Emblem: emblems.Schema_1970_01_01.Emblem - // Gliders Gliders: gliders.Schema_1970_01_01.Glider - // Continents Continents: continents.Schema_1970_01_01.Continent - // Titles Titles: titles.Schema_1970_01_01.Title + // Skins + Skins: skins.Schema_1970_01_01.Skin } diff --git a/src/types.ts b/src/types.ts index 45ae6ee..a85bf06 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,4 +5,5 @@ export type URL = string export type Language = 'en' | 'de' | 'es' | 'fr' export type Race = 'Human' | 'Norn' | 'Charr' | 'Sylvari' | 'Asura' export type Profession = 'Guardian' | 'Revenant' | 'Warrior' | 'Engineer' | 'Ranger' | 'Thief' | 'Elementalist' | 'Mesmer' | 'Necromancer' -export type Region = 'Tyria' | 'Maguuma' | 'Desert' | 'Tundra' \ No newline at end of file +export type Region = 'Tyria' | 'Maguuma' | 'Desert' | 'Tundra' +export type Rarity = 'Junk' | 'Basic' | 'Fine' | 'Masterwork' | 'Rare' | 'Exotic' | 'Ascended' | 'Legendary' \ No newline at end of file From e63a880514b557e28dcce798f93b6c1423707345 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Thu, 4 May 2023 13:45:25 +0200 Subject: [PATCH 30/72] Add tokeninfo --- src/endpoints/schemas/responses/tokeninfo.ts | 24 ++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ src/endpoints/schemas/schema_2019_05_22.ts | 7 +++--- src/types.ts | 1 + 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/endpoints/schemas/responses/tokeninfo.ts diff --git a/src/endpoints/schemas/responses/tokeninfo.ts b/src/endpoints/schemas/responses/tokeninfo.ts new file mode 100644 index 0000000..9562dc0 --- /dev/null +++ b/src/endpoints/schemas/responses/tokeninfo.ts @@ -0,0 +1,24 @@ +import { ISO8601, URL } from "../../../types" + +type Permission = 'account' | 'builds' | 'characters' | 'guilds' | 'inventories' | 'progression' | 'pvp' | 'tradingpost' | 'unlocks' | 'wallet' + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/tokeninfo} */ + export interface TokenInfo { + /** The first half of the API key that was requested. */ + id: number + /** The name given to the API key by the account owner. Warning: The value of this field is not escaped and may contain valid HTML, JavaScript, other code. Handle with care. */ + name: string + /** Array of strings describing which permissions the API key has. */ + permissions: Permission[] + } +} + +export namespace Schema_2022_05_19 { + export interface TokenInfo extends Schema_1970_01_01.TokenInfo { + type: 'APIKey' | 'Subtoken' + expires_at: ISO8601 + issued_at: ISO8601 + urls: URL[] + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 82d5cc4..10ccc7e 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -13,6 +13,7 @@ import * as dailycrafting from './responses/dailycrafting' import * as emblems from './responses/emblems' import * as skins from './responses/skins' import * as titles from './responses/titles' +import * as tokeninfo from './responses/tokeninfo' export interface Schema extends BaseSchema { // Achievements @@ -44,6 +45,8 @@ export interface Schema extends BaseSchema { Continents: continents.Schema_1970_01_01.Continent // Titles Titles: titles.Schema_1970_01_01.Title + // Tokeninfo + Tokeninfo: tokeninfo.Schema_1970_01_01.TokenInfo // Skins Skins: skins.Schema_1970_01_01.Skin } diff --git a/src/endpoints/schemas/schema_2019_05_22.ts b/src/endpoints/schemas/schema_2019_05_22.ts index 813759d..4b24899 100644 --- a/src/endpoints/schemas/schema_2019_05_22.ts +++ b/src/endpoints/schemas/schema_2019_05_22.ts @@ -1,5 +1,6 @@ import { Schema as BaseSchema } from './schema_2019_05_21' +import * as tokeninfo from './responses/tokeninfo' -export interface Schema extends BaseSchema { - -} \ No newline at end of file +export interface Schema extends Omit { + Tokeninfo: tokeninfo.Schema_2022_05_19.TokenInfo +} diff --git a/src/types.ts b/src/types.ts index a85bf06..48d3e89 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,7 @@ export type ItemID = number export type URL = string +export type ISO8601 = string export type Language = 'en' | 'de' | 'es' | 'fr' export type Race = 'Human' | 'Norn' | 'Charr' | 'Sylvari' | 'Asura' From 27f47949ebdfcb3aab8961e09b14513f8b6c3760 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Thu, 4 May 2023 13:48:46 +0200 Subject: [PATCH 31/72] Add nodes response --- src/endpoints/schemas/responses/nodes.ts | 6 ++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 src/endpoints/schemas/responses/nodes.ts diff --git a/src/endpoints/schemas/responses/nodes.ts b/src/endpoints/schemas/responses/nodes.ts new file mode 100644 index 0000000..9aa4d03 --- /dev/null +++ b/src/endpoints/schemas/responses/nodes.ts @@ -0,0 +1,6 @@ +type Node = string + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/account/home/nodes} */ + export type Nodes = Node[] +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 10ccc7e..7969de9 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -14,6 +14,7 @@ import * as emblems from './responses/emblems' import * as skins from './responses/skins' import * as titles from './responses/titles' import * as tokeninfo from './responses/tokeninfo' +import * as nodes from './responses/nodes' export interface Schema extends BaseSchema { // Achievements @@ -43,6 +44,8 @@ export interface Schema extends BaseSchema { Gliders: gliders.Schema_1970_01_01.Glider // Continents Continents: continents.Schema_1970_01_01.Continent + // Nodes + Nodes: nodes.Schema_1970_01_01.Nodes // Titles Titles: titles.Schema_1970_01_01.Title // Tokeninfo From b1a71c253abcae51216c9272d0a89297133ffa68 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Thu, 4 May 2023 13:52:23 +0200 Subject: [PATCH 32/72] Add minis response --- src/endpoints/schemas/responses/minis.ts | 19 +++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 src/endpoints/schemas/responses/minis.ts diff --git a/src/endpoints/schemas/responses/minis.ts b/src/endpoints/schemas/responses/minis.ts new file mode 100644 index 0000000..5414037 --- /dev/null +++ b/src/endpoints/schemas/responses/minis.ts @@ -0,0 +1,19 @@ +import { URL } from "../../../types" + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/minis} */ + export interface Mini { + /** The mini id. */ + id: number + /** The mini name. */ + name: string + /** A description of how to unlock the mini (only present on a few entries). */ + unlock: string + /** The mini icon. */ + icon: URL + /** The sort order that is used for displaying the mini in-game. */ + order: number + /** The item which unlocks the mini and can be resolved against /v2/items */ + item_id: number + } +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 7969de9..c071186 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -11,6 +11,7 @@ import * as continents from './responses/continents' import * as colors from './responses/colors' import * as dailycrafting from './responses/dailycrafting' import * as emblems from './responses/emblems' +import * as minis from './responses/minis' import * as skins from './responses/skins' import * as titles from './responses/titles' import * as tokeninfo from './responses/tokeninfo' @@ -44,6 +45,8 @@ export interface Schema extends BaseSchema { Gliders: gliders.Schema_1970_01_01.Glider // Continents Continents: continents.Schema_1970_01_01.Continent + // Minis + Minis: minis.Schema_1970_01_01.Mini // Nodes Nodes: nodes.Schema_1970_01_01.Nodes // Titles From d6bbe3682511af7f3159667174dc8721b4c672bd Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Thu, 4 May 2023 14:30:32 +0200 Subject: [PATCH 33/72] Add commerce and mailcarrier responses --- src/endpoints/schemas/responses/commerce.ts | 75 +++++++++++++++++++ .../schemas/responses/mailcarriers.ts | 21 ++++++ src/endpoints/schemas/schema.ts | 5 ++ src/endpoints/schemas/schema_1970_01_01.ts | 10 +++ 4 files changed, 111 insertions(+) create mode 100644 src/endpoints/schemas/responses/commerce.ts create mode 100644 src/endpoints/schemas/responses/mailcarriers.ts diff --git a/src/endpoints/schemas/responses/commerce.ts b/src/endpoints/schemas/responses/commerce.ts new file mode 100644 index 0000000..04ee72e --- /dev/null +++ b/src/endpoints/schemas/responses/commerce.ts @@ -0,0 +1,75 @@ +import { ISO8601 } from "../../../types" + +interface DeliveryItem { + /** The item's id, resolvable against v2/items. */ + id: number + /** The amount of this item ready for pickup. */ + count: number +} + +interface ListingDetails { + /** The number of individual listings this object refers to (e.g. two players selling at the same price will end up in the same listing) */ + listings: number + /** The sell offer or buy order price in coins. */ + unit_price: number + /** The amount of items being sold/bought in this listing. */ + quantity: number +} + + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/commerce/delivery} */ + export interface Delivery { + /** The amount of coins ready for pickup. */ + coins: number + items: DeliveryItem[] + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/commerce/exchange} */ + export interface Exchange { + /** The number of coins you required for a single gem. */ + coins_per_gem: number + /** The number of gems you get for the specified quantity of coins. */ + quantity: number + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/commerce/listings} */ + export interface Listing { + /** The item id. **/ + id: number + /** A list of all buy listings, descending from highest buy order. */ + buys: ListingDetails[] + /** A list of all sell listings, ascending from lowest sell offer. */ + sells: ListingDetails[] + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/commerce/prices} */ + export interface Price { + /** The item id. */ + id: number + /** Indicates whether or not a free to play account can purchase or sell this item on the trading post. */ + whitelisted: boolean + /** Buy information. */ + buys: ListingDetails + /** Sell information. */ + sells: ListingDetails + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/commerce/transactions} */ + interface Transaction { + /** Id of the transaction. */ + id: number + /** The item id. */ + item_id: number + /** The price in coins. */ + price: number + /** The quantity of the item. */ + quantity: number + /** The date of creation, using ISO-8601 standard. */ + created: ISO8601 + /** The date of purchase, using ISO-8601 standard. Not shown in current second-level endpoint. */ + purchased: ISO8601 + } + + export type Transactions = Transaction[] +} diff --git a/src/endpoints/schemas/responses/mailcarriers.ts b/src/endpoints/schemas/responses/mailcarriers.ts new file mode 100644 index 0000000..fb15934 --- /dev/null +++ b/src/endpoints/schemas/responses/mailcarriers.ts @@ -0,0 +1,21 @@ +import { URL } from "../../../types" + +type Flag = 'Default' + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/mailcarriers} */ + export interface Mailcarrier { + /** The id of the mail carrier. */ + id: number + /** An array of item ids used to unlock the mailcarrier. Can be resolved against v2/items */ + unlock_items?: number[] + /** The order in which the mailcarrier appears in a list. */ + order: number + /** The icon uri for the mail carrier. */ + icon: URL + /** The name of the mailcarrier as it appears in-game. */ + name: string + /** Additional flags on the item, such as "Default" */ + flags: Flag[] + } +} diff --git a/src/endpoints/schemas/schema.ts b/src/endpoints/schemas/schema.ts index 3e6640d..256f6b4 100644 --- a/src/endpoints/schemas/schema.ts +++ b/src/endpoints/schemas/schema.ts @@ -12,7 +12,9 @@ export interface Schema { Commerce: EndpointResponse, Continents: EndpointResponse, Currencies: EndpointResponse, + Exchange: EndpointResponse, Dailycrafting: EndpointResponse, + Delivery: EndpointResponse, Dungeons: EndpointResponse, Emblem: EndpointResponse, Events: EndpointResponse, @@ -25,6 +27,7 @@ export interface Schema { Itemstats: EndpointResponse, Legendaryarmory: EndpointResponse, Legends: EndpointResponse, + Listings: EndpointResponse, Mailcarriers: EndpointResponse, Mapchests: EndpointResponse, Maps: EndpointResponse, @@ -36,6 +39,7 @@ export interface Schema { Novelties: EndpointResponse, Outfits: EndpointResponse, Pets: EndpointResponse, + Prices: EndpointResponse, Professions: EndpointResponse, Pvp: EndpointResponse, Quaggans: EndpointResponse, @@ -51,6 +55,7 @@ export interface Schema { Titles: EndpointResponse, Tokeninfo: EndpointResponse, Traits: EndpointResponse, + Transactions: EndpointResponse, Worldbosses: EndpointResponse, Worlds: EndpointResponse, Wvw: EndpointResponse, diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index c071186..13b3a00 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -5,12 +5,14 @@ import * as achievements from './responses/achievements' import * as build from './responses/build' import * as cats from './responses/cats' import * as currencies from './responses/currencies' +import * as commerce from './responses/commerce' import * as dungeons from './responses/dungeons' import * as gliders from './responses/gliders' import * as continents from './responses/continents' import * as colors from './responses/colors' import * as dailycrafting from './responses/dailycrafting' import * as emblems from './responses/emblems' +import * as mailcarriers from './responses/mailcarriers' import * as minis from './responses/minis' import * as skins from './responses/skins' import * as titles from './responses/titles' @@ -35,6 +37,12 @@ export interface Schema extends BaseSchema { Currencies: currencies.Schema_1970_01_01.Currency // Colors Colors: colors.Schema_1970_01_01.Color + // Commerce + Delivery: commerce.Schema_1970_01_01.Delivery + Exchange: commerce.Schema_1970_01_01.Exchange + Listings: commerce.Schema_1970_01_01.Listing + Prices: commerce.Schema_1970_01_01.Price + Transactions: commerce.Schema_1970_01_01.Transactions // Dailycrafting Dailycrafting: dailycrafting.Schema_1970_01_01.DailyCrafting // Dungeon @@ -45,6 +53,8 @@ export interface Schema extends BaseSchema { Gliders: gliders.Schema_1970_01_01.Glider // Continents Continents: continents.Schema_1970_01_01.Continent + // Mailcarriers + Mailcarriers: mailcarriers.Schema_1970_01_01.Mailcarrier // Minis Minis: minis.Schema_1970_01_01.Mini // Nodes From 115264e0d62fd3c9df8cb05550a0fa3641a4290f Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 7 May 2023 13:21:10 +0200 Subject: [PATCH 34/72] Rename output directory from built/ to dist/ Fixes #2 --- .gitignore | 2 +- tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0eda85a..6379360 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -built/ +dist/ # Logs npm-debug.log* diff --git a/tsconfig.json b/tsconfig.json index 3930163..afbeb49 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "outDir": "./built", + "outDir": "./dist", "allowJs": true, "target": "es6" }, From e718502ce43a346db26c4ed5801f90789b86ea87 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 7 May 2023 13:34:43 +0200 Subject: [PATCH 35/72] Add finishers endpoint response --- src/endpoints/schemas/responses/finishers.ts | 17 +++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 src/endpoints/schemas/responses/finishers.ts diff --git a/src/endpoints/schemas/responses/finishers.ts b/src/endpoints/schemas/responses/finishers.ts new file mode 100644 index 0000000..815e03c --- /dev/null +++ b/src/endpoints/schemas/responses/finishers.ts @@ -0,0 +1,17 @@ +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/finishers} */ + export interface Finisher { + /** (default/null value: 0) - The id of the finisher. */ + id: number + /** (default/null value: "") - A description explaining how to acquire the finisher. */ + unlock_details: string + /** (optional) - An array of item ids used to unlock the finisher. Can be resolved against v2/items */ + unlock_items?: number[] + /** (default/null value: 0) - The order in which the finisher appears in a list. */ + order: number + /** (default/null value: "") - The icon uri for the finisher. */ + icon: string + /** (default/null value: "") - The name of the finisher as it appears in-game. */ + name: string + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 13b3a00..83d5196 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -7,6 +7,7 @@ import * as cats from './responses/cats' import * as currencies from './responses/currencies' import * as commerce from './responses/commerce' import * as dungeons from './responses/dungeons' +import * as finishers from './responses/finishers' import * as gliders from './responses/gliders' import * as continents from './responses/continents' import * as colors from './responses/colors' @@ -49,6 +50,8 @@ export interface Schema extends BaseSchema { Dungeons: dungeons.Schema_1970_01_01.Dungeon // Emblem Emblem: emblems.Schema_1970_01_01.Emblem + // Finisher + Finishers: finishers.Schema_1970_01_01.Finisher // Gliders Gliders: gliders.Schema_1970_01_01.Glider // Continents From ce8f6119760c4ba27b03f726db571be75c92b4ea Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 7 May 2023 15:25:29 +0200 Subject: [PATCH 36/72] Add legends endpoint reponse --- src/endpoints/schemas/responses/legends.ts | 23 ++++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ src/endpoints/schemas/schema_2019_12_19.ts | 5 +++-- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/endpoints/schemas/responses/legends.ts diff --git a/src/endpoints/schemas/responses/legends.ts b/src/endpoints/schemas/responses/legends.ts new file mode 100644 index 0000000..1220746 --- /dev/null +++ b/src/endpoints/schemas/responses/legends.ts @@ -0,0 +1,23 @@ +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/legends} */ + export interface Legend { + /** (default/null value: "") - The id of the Legend. */ + id: string + /** (default/null value: 0) - The id of the profession (swap Legend) skill resolvable against v2/skills. */ + swap: number + /** (default/null value: 0) - The id of the heal skill resolvable against v2/skills. */ + heal: number + /** (default/null value: 0) - The id of the elite skill resolvable against v2/skills. */ + elite: number + /** List of ids of the utility skills resolvable against v2/skills. */ + utilities: number[] + } +} + +export namespace Schema_2019_12_19 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/legends} */ + export interface Legend extends Schema_1970_01_01.Legend { + /** The legend code for a build template link. Available on schema version 2019-12-19T00:00:00.000Z or later. */ + code: number + } +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 83d5196..421f8b4 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -13,6 +13,7 @@ import * as continents from './responses/continents' import * as colors from './responses/colors' import * as dailycrafting from './responses/dailycrafting' import * as emblems from './responses/emblems' +import * as legends from './responses/legends' import * as mailcarriers from './responses/mailcarriers' import * as minis from './responses/minis' import * as skins from './responses/skins' @@ -56,6 +57,8 @@ export interface Schema extends BaseSchema { Gliders: gliders.Schema_1970_01_01.Glider // Continents Continents: continents.Schema_1970_01_01.Continent + // Legends + Legends: legends.Schema_1970_01_01.Legend // Mailcarriers Mailcarriers: mailcarriers.Schema_1970_01_01.Mailcarrier // Minis diff --git a/src/endpoints/schemas/schema_2019_12_19.ts b/src/endpoints/schemas/schema_2019_12_19.ts index ea80d79..9159cc1 100644 --- a/src/endpoints/schemas/schema_2019_12_19.ts +++ b/src/endpoints/schemas/schema_2019_12_19.ts @@ -1,5 +1,6 @@ import { Schema as BaseSchema } from './schema_2019_05_22' +import * as legends from './responses/legends' -export interface Schema extends BaseSchema { - +export interface Schema extends Omit { + Legends: legends.Schema_2019_12_19.Legend } \ No newline at end of file From b844d046105c2bb0f1552237f75a32fd245c60bb Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 7 May 2023 15:41:20 +0200 Subject: [PATCH 37/72] Fix a few compile errors --- src/endpoints/characters.ts | 2 +- src/endpoints/continents.ts | 4 ++-- src/endpoints/schemas/schema.ts | 5 +++++ src/endpoints/schemas/schema_1970_01_01.ts | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/endpoints/characters.ts b/src/endpoints/characters.ts index bb04b5d..1e00034 100644 --- a/src/endpoints/characters.ts +++ b/src/endpoints/characters.ts @@ -1,7 +1,7 @@ import { AbstractEndpoint } from '../endpoint' import { Schema } from './schemas/schema' -export class CharactersEndpoint extends AbstractEndpoint { +export class CharactersEndpoint extends AbstractEndpoint { public name: string constructor (client, name) { diff --git a/src/endpoints/continents.ts b/src/endpoints/continents.ts index e11f9ef..84f226b 100644 --- a/src/endpoints/continents.ts +++ b/src/endpoints/continents.ts @@ -11,12 +11,12 @@ export class ContinentsEndpoint extends AbstractEndpoint { +class FloorsEndpoint extends AbstractEndpoint { constructor (client, continentId) { super(client) this.url = `/v2/continents/${continentId}/floors` diff --git a/src/endpoints/schemas/schema.ts b/src/endpoints/schemas/schema.ts index 256f6b4..c463dcf 100644 --- a/src/endpoints/schemas/schema.ts +++ b/src/endpoints/schemas/schema.ts @@ -6,6 +6,7 @@ export interface Schema { Answers: EndpointResponse, Backstory: EndpointResponse, Build: EndpointResponse, + Category: EndpointResponse, Cats: EndpointResponse, Characters: EndpointResponse, Colors: EndpointResponse, @@ -13,6 +14,8 @@ export interface Schema { Continents: EndpointResponse, Currencies: EndpointResponse, Exchange: EndpointResponse, + Daily: EndpointResponse + Dailies: EndpointResponse Dailycrafting: EndpointResponse, Delivery: EndpointResponse, Dungeons: EndpointResponse, @@ -20,7 +23,9 @@ export interface Schema { Events: EndpointResponse, Files: EndpointResponse, Finishers: EndpointResponse, + Floor: EndpointResponse, Gliders: EndpointResponse, + Group: EndpointResponse Guild: EndpointResponse, Home: EndpointResponse, Items: EndpointResponse, diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 421f8b4..8379218 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -57,6 +57,7 @@ export interface Schema extends BaseSchema { Gliders: gliders.Schema_1970_01_01.Glider // Continents Continents: continents.Schema_1970_01_01.Continent + Floor: continents.Schema_1970_01_01.Floor // Legends Legends: legends.Schema_1970_01_01.Legend // Mailcarriers From c4a17bc71e7f256c41bb307650d87e0a7e683a46 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 7 May 2023 15:50:24 +0200 Subject: [PATCH 38/72] Remove nominal types from `get` --- src/endpoints/events.ts | 2 +- src/endpoints/guild.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/endpoints/events.ts b/src/endpoints/events.ts index 0c50958..84d4ba1 100644 --- a/src/endpoints/events.ts +++ b/src/endpoints/events.ts @@ -13,7 +13,7 @@ export class EventsEndpoint extends AbstractEndpoint { return super.get().then(transformV1Format) } - get (id: EventID) { + get (id: number) { return super.get(`?event_id=${id}`, true).then(json => transformV1Format(json)[0]) } } diff --git a/src/endpoints/guild.ts b/src/endpoints/guild.ts index 5314714..205a8d3 100644 --- a/src/endpoints/guild.ts +++ b/src/endpoints/guild.ts @@ -15,7 +15,7 @@ export class GuildEndpoint extends AbstractEndpoint { this.cacheTime = 60 * 60 } - get (id: GuildID) { + get (id: number) { return super.get(`/${id}`, true) } From e00ddc68c5503ad805ac377b3f51a8ac92ea194b Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 7 May 2023 15:58:07 +0200 Subject: [PATCH 39/72] Remove some stale types --- src/endpoints/achievements.ts | 95 ----------------------------------- 1 file changed, 95 deletions(-) diff --git a/src/endpoints/achievements.ts b/src/endpoints/achievements.ts index ec7bd06..92cbf82 100644 --- a/src/endpoints/achievements.ts +++ b/src/endpoints/achievements.ts @@ -1,101 +1,6 @@ import { AbstractEndpoint } from '../endpoint' import { Schema } from './schemas/schema' - -type Flag = 'PvE' | 'PvP' | 'WvW' | 'SpecialEvent' -type Product = 'GuildWars2' | 'HeartOfThorns' | 'PathOfFire' | 'EndOfDragons' -type Condition = 'HasAccess' | 'NoAccess' -type LevelTuple = [number, number] -type LevelObj = { min: number, max: number } -type RequiredAccess = { product: Product, condition: Condition } - -export namespace SchemaOld { - /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily} */ - type Daily = { - id: number, - level: LevelObj, - required_access: Product[] - } - - /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ - export interface Dailies { - pve: Daily[], - wvw: Daily[], - fractals: Daily[], - special: Daily[] - } - - /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/categories} */ - export interface Category { - id: number, - name: string, - description: string, - order: number, - icon: string, - achievements: number[], - } -} - -// If using schema 2019-05-16T00:00:00.000Z or later -export namespace SchemaNew { - /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily} */ - type Daily = { - id: number, - level: LevelObj, - required_access?: RequiredAccess - } - - /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/daily/tomorrow} */ - export interface Dailies { - pve: Daily[], - wvw: Daily[], - fractals: Daily[], - special: Daily[] - } - - /** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/categories} */ - export interface Category { - id: number, - name: string, - description: string, - order: number, - icon: string, - achievements: { - id: number, - required_access: RequiredAccess - flags: Flag[], - level: [number, number] - }, - tomorrow: { - id: number, - required_access: RequiredAccess, - flags: Flag[], - level: LevelTuple - } - } -} - -/** {@link https://wiki.guildwars2.com/wiki/API:2/achievements/groups} */ -interface Group { - id: string, - name: string, - description: string, - order: number, - categories: number[] -} - -/** {@link https://wiki.guildwars2.com/wiki/API:2/account/achievements} */ -interface Achievement { - id: number, - bits?: number, - current?: number, - max?: number, - done: boolean, - repeated?: number, - unlocked?: number -} - - export class AchievementsEndpoint extends AbstractEndpoint { constructor (client) { super(client) From 021a594901a9cbbec24141f53af8fd9a144a04cd Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 7 May 2023 22:57:39 +0200 Subject: [PATCH 40/72] Add traits endpoint response --- src/endpoints/gliders.ts | 3 +- src/endpoints/schemas/responses/traits.ts | 172 +++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 + 3 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 src/endpoints/schemas/responses/traits.ts diff --git a/src/endpoints/gliders.ts b/src/endpoints/gliders.ts index 6916720..62f01c5 100644 --- a/src/endpoints/gliders.ts +++ b/src/endpoints/gliders.ts @@ -1,6 +1,7 @@ import { AbstractEndpoint } from '../endpoint' +import { Schema } from './schemas/schema' -export class GlidersEndpoint extends AbstractEndpoint { +export class GlidersEndpoint extends AbstractEndpoint { constructor (client) { super(client) this.url = '/v2/gliders' diff --git a/src/endpoints/schemas/responses/traits.ts b/src/endpoints/schemas/responses/traits.ts new file mode 100644 index 0000000..c4e545c --- /dev/null +++ b/src/endpoints/schemas/responses/traits.ts @@ -0,0 +1,172 @@ +type FactTypeName = 'AttributeAdjust' | 'Buff' | 'BuffConversion' | 'ComboField' | 'ComboFinisher' | 'Damage' | 'Distance' | 'NoData' | 'Number' | 'Percent' | 'PrefixedBuff' | 'Radius' | 'Range' | 'Recharge' | 'Time' | 'Unblockable' +type FactType = AttributeAdjust | Buff | BuffConversion | ComboField | ComboFinisher | Damage | Distance | NoData | Number | Percent | PrefixedBuff | Radius | Range | Recharge | Time | Unblockable +type TraitType = 'Major' | 'Minor' + +interface Skill { + /** The ID of the skill. */ + id: number + /** The name of the skill. */ + name: string + /** The description of the skill. */ + description: string + /** The URL for the icon of the skill. */ + icon: string + /** A list of tooltip facts associated with the skill. (See below.) */ + facts?: Array + /** A list of additions or changes to tooltip facts where there is interplay between traits. (See below.) */ + traited_facts?: Array +} + +interface TraitedFact { + /** Specifies which trait has to be selected in order for this fact to take effect. */ + requires_trait: number + /** This specifies the array index of the facts object it will override, if the trait specified in requires_trait is selected. If this field is omitted, then the fact contained within this object is to be appended to the existing facts array. */ + overrides?: number +} + +interface Fact { + /** An arbitrary localized string describing the fact. Not included with all facts. */ + text?: string + /** A URL to the icon shown with the fact. Not included with all facts. */ + icon?: string + /** Defines what additional fields the object will contain, and what type of fact it is. Can be one of the following: */ + type: T +} + +interface AttributeAdjust extends Fact<'AttributeAdjust'> { + /** The amount target gets adjusted, based on a level 80 character at base stats. */ + value: number + /** The attribute this fact adjusts. Note that a value of Healing indicates the fact is a heal, and Ferocity is encoded at CritDamage. */ + target: string +} + +interface Buff extends Fact<'Buff'> { + /** The boon, condition, or effect referred to by the fact. */ + status: string + /** The description of the status effect. */ + description?: string + /** The number of stacks applied. */ + apply_count?: number + /** The duration of the effect in seconds. Note that some facts of this type are just used to display the buff icon with text; in this case, duration is usually 0, or omitted entirely. */ + duration?: number +} + +interface BuffConversion extends Fact<'BuffConversion'> { + /** The attribute that is used to calculate the attribute gain. */ + source: string + /** How much of the source attribute is added to target. */ + percent: string + /** The attribute that gets added to. */ + target: string +} + +interface ComboField extends Fact<'ComboField'> { + /** The type of field. */ + field_type: 'Air' | 'Dark' | 'Fire' | 'Ice' | 'Light' | 'Lightning' | 'Poison' | 'Smoke' | 'Ethereal' | 'Water' +} + +interface ComboFinisher extends Fact<'ComboFinisher'> { + /** The type of finisher. */ + finisher_type: 'Blast' | 'Leap' | 'Projectile' | 'Whirl' + /** The percent chance that the finisher will trigger. */ + percent: number +} + +interface Damage extends Fact<'Damage'> { + /** The amount of times the damage hits. */ + hit_count: number +} + +interface Distance extends Fact<'Distance'> { + /** The distance value. */ + distance: number +} + +interface NoData extends Fact<'NoData'> { +} + +interface Number extends Fact<'Number'> { + /** The number value as referenced by text. */ + value: number +} + +interface Percent extends Fact<'Percent'> { + /** The percentage value as referenced by text. */ + value: number +} + +interface PrefixedBuff extends Fact<'Percent'> { + /** The boon, condition, or effect referred to by the fact. */ + status: string + /** The description of the status effect. */ + description?: string + /** The number of stacks applied. */ + apply_count?: number + /** The duration of the effect in seconds. Note that some facts of this type are just used to display the buff icon with text; in this case, duration is usually 0, or omitted entirely. */ + duration?: number + prefix: { + text: string + icon: string + status: string + description?: string + } +} + +interface Radius extends Fact<'Radius'> { + /** The radius value. */ + distance: number +} + +interface Range extends Fact<'Range'> { + /** The range of the trait/skill. */ + value: number +} + +interface Recharge extends Fact<'Recharge'> { + /** The recharge time in seconds. */ + recharge: number +} + +interface Time extends Fact<'Time'> { + /** The time value in seconds. */ + duration: number +} + +interface Unblockable extends Fact<'Unblockable'> { + /** Always true. */ + value: true +} + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/traits} */ + export interface Trait { + /** The trait id. */ + id: number + /** The trait name. */ + name: string + /** The trait's icon URL. */ + icon: string + /** The trait description. */ + description: string + /** The id of the specialization this trait belongs to. */ + specialization: number + /** The trait's tier (Adept, Master, Grandmaster) as a value from 1-3. Elite specializations also contain a tier 0 minor trait, describing which weapon the elite specialization gains access to. */ + tier: number + /** Either Major or Minor depending on the trait's slot. Minor traits are the ones given immediately when choosing a specialization. */ + slot: TraitType + /** A list of tooltip facts associated with the trait itself. (See below.) */ + facts?: Array + /** A list of additions or changes to tooltip facts where there is interplay between traits. (See below.) */ + traited_facts?: Array + /** A list of skills which may be triggered by the trait. (See below.) */ + skills?: Array + } +} + + + + + + + + diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 8379218..50dc9a3 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -20,6 +20,7 @@ import * as skins from './responses/skins' import * as titles from './responses/titles' import * as tokeninfo from './responses/tokeninfo' import * as nodes from './responses/nodes' +import * as traits from './responses/traits' export interface Schema extends BaseSchema { // Achievements @@ -70,6 +71,8 @@ export interface Schema extends BaseSchema { Titles: titles.Schema_1970_01_01.Title // Tokeninfo Tokeninfo: tokeninfo.Schema_1970_01_01.TokenInfo + // Trait + Traits: traits.Schema_1970_01_01.Trait // Skins Skins: skins.Schema_1970_01_01.Skin } From 8acaf749c575991b80c4daca5b42626f11109d27 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Fri, 26 May 2023 10:30:09 +0200 Subject: [PATCH 41/72] Add races endpoint response --- src/endpoints/schemas/responses/races.ts | 9 +++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 4 ++++ 2 files changed, 13 insertions(+) create mode 100644 src/endpoints/schemas/responses/races.ts diff --git a/src/endpoints/schemas/responses/races.ts b/src/endpoints/schemas/responses/races.ts new file mode 100644 index 0000000..48326e6 --- /dev/null +++ b/src/endpoints/schemas/responses/races.ts @@ -0,0 +1,9 @@ +import { Race as R } from '../../../types' + +export namespace Schema_1970_01_01 { + export interface Race { + // FIXME: better alias? + id: R + skills: number[] + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 50dc9a3..14a23d3 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -21,6 +21,8 @@ import * as titles from './responses/titles' import * as tokeninfo from './responses/tokeninfo' import * as nodes from './responses/nodes' import * as traits from './responses/traits' +import * as races from './responses/races' +import { RacesEndpoint } from '../races' export interface Schema extends BaseSchema { // Achievements @@ -67,6 +69,8 @@ export interface Schema extends BaseSchema { Minis: minis.Schema_1970_01_01.Mini // Nodes Nodes: nodes.Schema_1970_01_01.Nodes + // Races + Races: races.Schema_1970_01_01.Race // Titles Titles: titles.Schema_1970_01_01.Title // Tokeninfo From 7b92130e0d326d29a6e2aeb155cb568ed44cc6af Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Fri, 26 May 2023 10:37:21 +0200 Subject: [PATCH 42/72] Add quaggans endpoint response --- src/endpoints/schemas/responses/quaggans.ts | 11 +++++++++++ src/endpoints/schemas/responses/races.ts | 1 + src/endpoints/schemas/schema_1970_01_01.ts | 5 ++++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/endpoints/schemas/responses/quaggans.ts diff --git a/src/endpoints/schemas/responses/quaggans.ts b/src/endpoints/schemas/responses/quaggans.ts new file mode 100644 index 0000000..efa0309 --- /dev/null +++ b/src/endpoints/schemas/responses/quaggans.ts @@ -0,0 +1,11 @@ +import { Race as R, URL } from '../../../types' + +type Quaggan = string + +export namespace Schema_1970_01_01 { + /** @link {https://wiki.guildwars2.com/wiki/API:2/quaggans} */ + export interface Quaggan { + id: Quaggan + url: URL + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/responses/races.ts b/src/endpoints/schemas/responses/races.ts index 48326e6..900ce9e 100644 --- a/src/endpoints/schemas/responses/races.ts +++ b/src/endpoints/schemas/responses/races.ts @@ -1,6 +1,7 @@ import { Race as R } from '../../../types' export namespace Schema_1970_01_01 { + /** @link {https://wiki.guildwars2.com/wiki/API:2/races} */ export interface Race { // FIXME: better alias? id: R diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 14a23d3..53116a0 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -22,7 +22,8 @@ import * as tokeninfo from './responses/tokeninfo' import * as nodes from './responses/nodes' import * as traits from './responses/traits' import * as races from './responses/races' -import { RacesEndpoint } from '../races' +import * as quaggans from './responses/quaggans' + export interface Schema extends BaseSchema { // Achievements @@ -69,6 +70,8 @@ export interface Schema extends BaseSchema { Minis: minis.Schema_1970_01_01.Mini // Nodes Nodes: nodes.Schema_1970_01_01.Nodes + // Quaggans + Quaggans: quaggans.Schema_1970_01_01.Quaggan // Races Races: races.Schema_1970_01_01.Race // Titles From 54129cd4cc020f2b912daa82d375d7e715fe4703 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Fri, 26 May 2023 17:59:46 +0200 Subject: [PATCH 43/72] Add novelties endpoint response --- src/endpoints/schemas/responses/novelties.ts | 21 ++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 src/endpoints/schemas/responses/novelties.ts diff --git a/src/endpoints/schemas/responses/novelties.ts b/src/endpoints/schemas/responses/novelties.ts new file mode 100644 index 0000000..1fc9a46 --- /dev/null +++ b/src/endpoints/schemas/responses/novelties.ts @@ -0,0 +1,21 @@ +import { URL } from "../../../types" + +type Slot = 'Chair' | 'Music' | 'HeldItem' | 'Miscellaneous' | 'Tonic' + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/novelties} */ + export interface Novelty { + /** The id of the novelty. */ + id: number + /** The name of the novelty as it appears in-game. */ + name: string + /** The in-game novelty description. */ + description: string + /** The icon url for the novelty. */ + icon: string + /** The slot which the novelty appears in the UI for. */ + slot: Slot + /** An array of item ids used to unlock the novelty. Can be resolved against v2/items */ + unlock_item: number[] + } +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 53116a0..dbbf655 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -23,6 +23,7 @@ import * as nodes from './responses/nodes' import * as traits from './responses/traits' import * as races from './responses/races' import * as quaggans from './responses/quaggans' +import * as novelties from './responses/novelties' export interface Schema extends BaseSchema { @@ -70,6 +71,8 @@ export interface Schema extends BaseSchema { Minis: minis.Schema_1970_01_01.Mini // Nodes Nodes: nodes.Schema_1970_01_01.Nodes + // Novelties + Novelties: novelties.Schema_1970_01_01.Novelty // Quaggans Quaggans: quaggans.Schema_1970_01_01.Quaggan // Races From b861fb93c66b17f478771cb851903220fa8a1f74 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Fri, 26 May 2023 18:03:14 +0200 Subject: [PATCH 44/72] Add outfits response --- src/endpoints/schemas/responses/outfits.ts | 13 +++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 16 insertions(+) create mode 100644 src/endpoints/schemas/responses/outfits.ts diff --git a/src/endpoints/schemas/responses/outfits.ts b/src/endpoints/schemas/responses/outfits.ts new file mode 100644 index 0000000..f1b4d63 --- /dev/null +++ b/src/endpoints/schemas/responses/outfits.ts @@ -0,0 +1,13 @@ +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/outfits} */ + export interface Outfit { + /** The id of the outfit. */ + id: number + /** The name of the outfit (this is also the outfit displayed over a character in-game.) */ + name: string + /** The icon for the selected outfit. */ + icon: string + /** An array of item id which unlock this outfit; resolvable against v2/items. */ + unlock_items: number[] + } +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index dbbf655..6f8296d 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -24,6 +24,7 @@ import * as traits from './responses/traits' import * as races from './responses/races' import * as quaggans from './responses/quaggans' import * as novelties from './responses/novelties' +import * as outfits from './responses/outfits' export interface Schema extends BaseSchema { @@ -73,6 +74,8 @@ export interface Schema extends BaseSchema { Nodes: nodes.Schema_1970_01_01.Nodes // Novelties Novelties: novelties.Schema_1970_01_01.Novelty + // Outfits + Outfits: outfits.Schema_1970_01_01.Outfit // Quaggans Quaggans: quaggans.Schema_1970_01_01.Quaggan // Races From 6ae64358d0a739825f89a9e29b04e4bdb2965244 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Fri, 26 May 2023 18:08:27 +0200 Subject: [PATCH 45/72] Add pets response --- src/endpoints/schemas/responses/novelties.ts | 2 -- src/endpoints/schemas/responses/pets.ts | 19 +++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/endpoints/schemas/responses/pets.ts diff --git a/src/endpoints/schemas/responses/novelties.ts b/src/endpoints/schemas/responses/novelties.ts index 1fc9a46..8fde90f 100644 --- a/src/endpoints/schemas/responses/novelties.ts +++ b/src/endpoints/schemas/responses/novelties.ts @@ -1,5 +1,3 @@ -import { URL } from "../../../types" - type Slot = 'Chair' | 'Music' | 'HeldItem' | 'Miscellaneous' | 'Tonic' export namespace Schema_1970_01_01 { diff --git a/src/endpoints/schemas/responses/pets.ts b/src/endpoints/schemas/responses/pets.ts new file mode 100644 index 0000000..eed6066 --- /dev/null +++ b/src/endpoints/schemas/responses/pets.ts @@ -0,0 +1,19 @@ +interface Skill { + id: number +} + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/pets} */ + export interface Pet { + /** The codeid of the pet. */ + id: number + /** The name of the pet. */ + name: string + /** The description of the pet. */ + description: string + /** The icon uri for the pet. */ + icon: string + /** The id of the skill, to be resolved against v2/skills. */ + skills: Skill[] + } +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 6f8296d..7e0b11a 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -25,6 +25,7 @@ import * as races from './responses/races' import * as quaggans from './responses/quaggans' import * as novelties from './responses/novelties' import * as outfits from './responses/outfits' +import * as pets from './responses/pets' export interface Schema extends BaseSchema { @@ -76,6 +77,8 @@ export interface Schema extends BaseSchema { Novelties: novelties.Schema_1970_01_01.Novelty // Outfits Outfits: outfits.Schema_1970_01_01.Outfit + // Pets + Pets: pets.Schema_1970_01_01.Pets // Quaggans Quaggans: quaggans.Schema_1970_01_01.Quaggan // Races From 9750d818c813d10c9a4251a65d5498ce10258e92 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Fri, 26 May 2023 23:45:25 +0200 Subject: [PATCH 46/72] Add profession responses --- .../schemas/responses/professions.ts | 86 +++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 + src/endpoints/schemas/schema_2019_12_19.ts | 4 +- src/types.ts | 4 +- 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 src/endpoints/schemas/responses/professions.ts diff --git a/src/endpoints/schemas/responses/professions.ts b/src/endpoints/schemas/responses/professions.ts new file mode 100644 index 0000000..12703e5 --- /dev/null +++ b/src/endpoints/schemas/responses/professions.ts @@ -0,0 +1,86 @@ +import { Profession } from "../../../types" +import { Attunement, Weapon } from "../../../types" + +type WeaponFlag = 'Mainhand' | 'Offhand' | 'TwoHand' | 'Aquatic' +type SkillSlot = 'Profession_1' | 'Utility' | 'Heal' | 'Elite' +type ProfessionFlag = 'NotRacialSkills' | 'NoWeaponSwap' +type TrainingCategory = 'Skills' | 'Specializations' | 'EliteSpecializations' + +interface Track { + /** The cost to train this skill or trait. */ + cost: number +} + +interface Trait extends Track { + type: 'Trait' + /** This field is only present if type is Trait. */ + trait_id: number +} + +interface Skill extends Track { + type: 'Skill' + /** This field is only present if type is Skill. */ + skill_id: number +} + +interface Training { + /** The id of the API:2/skills or API:2/specializations inidcated by the category. */ + id: number + /** The category for the training object. */ + category: TrainingCategory + /** The name of the skill or specialization inidcated by the category and id. */ + name: string + /** List of skills and traits training details tracks objects. */ + track: Array +} + +interface WeaponSkill { + /** The id of the API:2/skills. */ + id: number + /** The skill bar slot that this weapon skill can be used in. */ + slot: SkillSlot + /** The name of the offhand weapon this skill requires to be equipped. This field is usually only present for Thief skills. */ + offhand?: Weapon + /** The Elementalist attunement that this skill requires. This field is usually only present for Elementalist skills. */ + attunement?: Attunement + /** The name of the class the skill was stolen from. This only applies to thief stolen skills. */ + source?: Profession +} + +interface WeaponInfo { + flag: WeaponFlag[] + /** he API:2/specializations id of the required specialization to use this weapon. This field is only present if the weapon requires a specialization to be used. */ + specialization?: number + /** The list of weapon skills objects. */ + skills: WeaponSkill[] +} + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/professions} */ + export interface Profession { + /** The profession id. */ + id: string + /** The name of the profession. */ + name: string + /** The icon for the profession. */ + icon: string + /** The large icon for the profession. */ + icon_big: string + /** List of API:2/specializations ids. */ + specializations: number[] + /** List of training details objects. */ + training: Training[] + /** The weapons available for this profession. The key indicates the weapon type. */ + weapons: {[key in Weapon]?: WeaponInfo} + flags: ProfessionFlag[] + } +} + +export namespace Schema_2019_12_19 { + export interface Profession extends Schema_1970_01_01.Profession { + /** The profession code for a build template link. Available on schema version 2019-12-19T00:00:00.000Z or later. */ + code: number + /** Contains arrays of two numbers. The first number is a skill palette ID obtained from a build template link, the second number is a skill ID. This is so you can resolve palette IDs obtained from a build template link to API:2/skills. This is only available on schema version 2019-12-19T00:00:00.000Z */ + skills_by_palette: Array<[number, number]> + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 7e0b11a..65d12f0 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -26,6 +26,7 @@ import * as quaggans from './responses/quaggans' import * as novelties from './responses/novelties' import * as outfits from './responses/outfits' import * as pets from './responses/pets' +import * as professions from './responses/professions' export interface Schema extends BaseSchema { @@ -79,6 +80,8 @@ export interface Schema extends BaseSchema { Outfits: outfits.Schema_1970_01_01.Outfit // Pets Pets: pets.Schema_1970_01_01.Pets + // Professions + Professions: professions.Schema_1970_01_01.Profession // Quaggans Quaggans: quaggans.Schema_1970_01_01.Quaggan // Races diff --git a/src/endpoints/schemas/schema_2019_12_19.ts b/src/endpoints/schemas/schema_2019_12_19.ts index 9159cc1..7a2d269 100644 --- a/src/endpoints/schemas/schema_2019_12_19.ts +++ b/src/endpoints/schemas/schema_2019_12_19.ts @@ -1,6 +1,8 @@ import { Schema as BaseSchema } from './schema_2019_05_22' import * as legends from './responses/legends' +import * as professions from './responses/professions' -export interface Schema extends Omit { +export interface Schema extends Omit { Legends: legends.Schema_2019_12_19.Legend + Professions: professions.Schema_2019_12_19.Profession } \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 48d3e89..2c47bea 100644 --- a/src/types.ts +++ b/src/types.ts @@ -7,4 +7,6 @@ export type Language = 'en' | 'de' | 'es' | 'fr' export type Race = 'Human' | 'Norn' | 'Charr' | 'Sylvari' | 'Asura' export type Profession = 'Guardian' | 'Revenant' | 'Warrior' | 'Engineer' | 'Ranger' | 'Thief' | 'Elementalist' | 'Mesmer' | 'Necromancer' export type Region = 'Tyria' | 'Maguuma' | 'Desert' | 'Tundra' -export type Rarity = 'Junk' | 'Basic' | 'Fine' | 'Masterwork' | 'Rare' | 'Exotic' | 'Ascended' | 'Legendary' \ No newline at end of file +export type Rarity = 'Junk' | 'Basic' | 'Fine' | 'Masterwork' | 'Rare' | 'Exotic' | 'Ascended' | 'Legendary' +export type Weapon = 'Axe' | 'Dagger' | 'Mace' | 'Pistol' | 'Sword' | 'Scepter' | 'Focus' | 'Shield' | 'Torch' | 'Warhorn' | 'Greatsword' | 'Hammer' | 'Longbow' | 'Rifle' | 'Shortbow' | 'Staff' | 'Speargun' | 'Spear' | 'Trident' +export type Attunement = 'Fire' | 'Water' | 'Wind' | 'Earth' \ No newline at end of file From 6fbb897ddd92f3135b3e06634b873004d13ded43 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Fri, 26 May 2023 23:49:05 +0200 Subject: [PATCH 47/72] Add files response --- src/endpoints/schemas/responses/files.ts | 11 +++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 14 insertions(+) create mode 100644 src/endpoints/schemas/responses/files.ts diff --git a/src/endpoints/schemas/responses/files.ts b/src/endpoints/schemas/responses/files.ts new file mode 100644 index 0000000..bae9938 --- /dev/null +++ b/src/endpoints/schemas/responses/files.ts @@ -0,0 +1,11 @@ +import { URL } from "../../../types" + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/wiki/API:2/files} */ + export interface File { + /** The file identifier. */ + id: string + /** The URL to the image. */ + icon: URL + } +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 65d12f0..34e4d97 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -27,6 +27,7 @@ import * as novelties from './responses/novelties' import * as outfits from './responses/outfits' import * as pets from './responses/pets' import * as professions from './responses/professions' +import * as files from './responses/files' export interface Schema extends BaseSchema { @@ -59,6 +60,8 @@ export interface Schema extends BaseSchema { Dungeons: dungeons.Schema_1970_01_01.Dungeon // Emblem Emblem: emblems.Schema_1970_01_01.Emblem + // Files + Files: files.Schema_1970_01_01.File // Finisher Finishers: finishers.Schema_1970_01_01.Finisher // Gliders From 1eecb8d585097aa6a4c822a9eb5ab6788e0e4405 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Fri, 26 May 2023 23:50:37 +0200 Subject: [PATCH 48/72] Fix typo --- src/endpoints/schemas/schema_1970_01_01.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 34e4d97..3807bb5 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -82,7 +82,7 @@ export interface Schema extends BaseSchema { // Outfits Outfits: outfits.Schema_1970_01_01.Outfit // Pets - Pets: pets.Schema_1970_01_01.Pets + Pets: pets.Schema_1970_01_01.Pet // Professions Professions: professions.Schema_1970_01_01.Profession // Quaggans From f0dfaf57f31852b902fd6859caa2d025b8ad698f Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 27 May 2023 08:42:14 +0200 Subject: [PATCH 49/72] Add idea.txt --- idea.txt | 6 ++++++ package.json | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 idea.txt diff --git a/idea.txt b/idea.txt new file mode 100644 index 0000000..80d7c2d --- /dev/null +++ b/idea.txt @@ -0,0 +1,6 @@ +use typescript-json-schema to generate schema info: +```sh +▶ node_modules/typescript-json-schema/bin/typescript-json-schema "src/endpoints/schemas/responses/*" "*" +``` + +use that in a schema validator, for example in ajv \ No newline at end of file diff --git a/package.json b/package.json index f1e4e2a..91205d8 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "jest": "^23.6.0", "mockdate": "^2.0.2", "redis": "^2.6.2", - "standard": "^12.0.1" + "standard": "^12.0.1", + "typescript-json-schema": "^0.56.0" } } From 7c5177ca3461fef8805fdeaea327e76fbbcec193 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 27 May 2023 08:44:08 +0200 Subject: [PATCH 50/72] Revert --- idea.txt | 6 ------ package.json | 3 +-- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 idea.txt diff --git a/idea.txt b/idea.txt deleted file mode 100644 index 80d7c2d..0000000 --- a/idea.txt +++ /dev/null @@ -1,6 +0,0 @@ -use typescript-json-schema to generate schema info: -```sh -▶ node_modules/typescript-json-schema/bin/typescript-json-schema "src/endpoints/schemas/responses/*" "*" -``` - -use that in a schema validator, for example in ajv \ No newline at end of file diff --git a/package.json b/package.json index 91205d8..f1e4e2a 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "jest": "^23.6.0", "mockdate": "^2.0.2", "redis": "^2.6.2", - "standard": "^12.0.1", - "typescript-json-schema": "^0.56.0" + "standard": "^12.0.1" } } From 160537c29cadff535dea281218fdf42fced793cd Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 27 May 2023 09:16:14 +0200 Subject: [PATCH 51/72] Add mastery response --- src/endpoints/schemas/responses/masteries.ts | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/endpoints/schemas/responses/masteries.ts diff --git a/src/endpoints/schemas/responses/masteries.ts b/src/endpoints/schemas/responses/masteries.ts new file mode 100644 index 0000000..01b7b8f --- /dev/null +++ b/src/endpoints/schemas/responses/masteries.ts @@ -0,0 +1,34 @@ +interface MasteryLevel { + /** The name for the given mastery. */ + name: string + /** The in game description for the given mastery. */ + description: string + /** The in game instructions for the given mastery. */ + instruction: string + /** The icon uri for the mastery. */ + icon: string + /** The amount of mastery points required to unlock the mastery. */ + point_cost: number + /** The total amount of experience needed to train the given mastery level. This total is non-cumulative between levels. */ + exp_cost: number +} + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/masteries} */ + export interface Mastery { + /** The id of the mastery. */ + id: number + /** The name of the selected mastery. */ + name: string + /** The written out requirements to unlock the mastery track. */ + requirement: string + /** The order in which the mastery track appears in a list. */ + order: number + /** The background uri for the mastery track. */ + background: string + /** The in-game region in which the mastery track belongs. */ + region: string + /** An array containing the information of each mastery level. */ + levels: Array + } +} \ No newline at end of file From f284a7fc50d17f3a150a040d37ff90472d305d90 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 27 May 2023 09:37:24 +0200 Subject: [PATCH 52/72] Add mounts response --- src/endpoints/schemas/responses/mounts.ts | 41 ++++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 7 ++++ src/types.ts | 4 ++- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/endpoints/schemas/responses/mounts.ts diff --git a/src/endpoints/schemas/responses/mounts.ts b/src/endpoints/schemas/responses/mounts.ts new file mode 100644 index 0000000..94b9b60 --- /dev/null +++ b/src/endpoints/schemas/responses/mounts.ts @@ -0,0 +1,41 @@ +import { ColorMaterial, WeaponSlot } from "../../../types" + +interface MountSkill { + id: number + slot: WeaponSlot +} + +interface DyeSlot { + color_id: number + material: ColorMaterial +} + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/mounts/types} */ + export interface Type { + /** The id of the mount. */ + id: string + /** The name of the mount type as it appears in-game. */ + name: string + /** The mount skin a mount has when first obtained. Can be resolved against v2/mounts/skins */ + default_skin: number + /** An array of mount skin ids. Can be resolved against v2/mounts/skins */ + skins: Array + /** Each object contains a key-value pair for the skill id and weapon slot. */ + skills: MountSkill[] + } + + /** {@link https://wiki.guildwars2.com/API:2/mounts/skins} */ + export interface Skin { + /** The id of the mount skin. */ + id: string + /** The name of the mount as it appears in-game. */ + name: string + /** The full icon URL. */ + icon: string + /** The mount type id for the given mount skin. Can be resolved against v2/mounts/types */ + mount: string + /** Each object contains a key-value pair for the color (dye) id and material. Can be resolved against v2/colors */ + dye_slots: DyeSlot[] + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 3807bb5..b8cfd4c 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -28,6 +28,8 @@ import * as outfits from './responses/outfits' import * as pets from './responses/pets' import * as professions from './responses/professions' import * as files from './responses/files' +import * as masteries from './responses/masteries' +import * as mounts from './responses/mounts' export interface Schema extends BaseSchema { @@ -73,6 +75,11 @@ export interface Schema extends BaseSchema { Legends: legends.Schema_1970_01_01.Legend // Mailcarriers Mailcarriers: mailcarriers.Schema_1970_01_01.Mailcarrier + // Masteries + Masteries: masteries.Schema_1970_01_01.Mastery + // Mounts + MountType: mounts.Schema_1970_01_01.Type + MountSkin: mounts.Schema_1970_01_01.Skin // Minis Minis: minis.Schema_1970_01_01.Mini // Nodes diff --git a/src/types.ts b/src/types.ts index 2c47bea..50e0133 100644 --- a/src/types.ts +++ b/src/types.ts @@ -9,4 +9,6 @@ export type Profession = 'Guardian' | 'Revenant' | 'Warrior' | 'Engineer' | 'Ran export type Region = 'Tyria' | 'Maguuma' | 'Desert' | 'Tundra' export type Rarity = 'Junk' | 'Basic' | 'Fine' | 'Masterwork' | 'Rare' | 'Exotic' | 'Ascended' | 'Legendary' export type Weapon = 'Axe' | 'Dagger' | 'Mace' | 'Pistol' | 'Sword' | 'Scepter' | 'Focus' | 'Shield' | 'Torch' | 'Warhorn' | 'Greatsword' | 'Hammer' | 'Longbow' | 'Rifle' | 'Shortbow' | 'Staff' | 'Speargun' | 'Spear' | 'Trident' -export type Attunement = 'Fire' | 'Water' | 'Wind' | 'Earth' \ No newline at end of file +export type Attunement = 'Fire' | 'Water' | 'Wind' | 'Earth' +export type WeaponSlot = 'Weapon_1' +export type ColorMaterial = 'cloth' | 'metal' | 'leather' | 'fur' \ No newline at end of file From 7853cf484cbbf65cf1ba40c5081ec23f9cebd788 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 28 May 2023 21:19:09 +0200 Subject: [PATCH 53/72] Add raids response --- src/endpoints/schemas/responses/raids.ts | 23 ++++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 26 insertions(+) create mode 100644 src/endpoints/schemas/responses/raids.ts diff --git a/src/endpoints/schemas/responses/raids.ts b/src/endpoints/schemas/responses/raids.ts new file mode 100644 index 0000000..23704ff --- /dev/null +++ b/src/endpoints/schemas/responses/raids.ts @@ -0,0 +1,23 @@ +type EventType = 'Checkpoint' | 'Boss' + +interface Event { + /** The event/encounter name. */ + id: string + /** The type of events.*/ + type: EventType +} + +interface Wing { + /** The given name for the dungeon path. */ + id: string + events: Event[] +} + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/raids} */ + export interface Raid { + /** The name of the dungeon. */ + id: string + wings: Wing[] + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index b8cfd4c..aef2941 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -30,6 +30,7 @@ import * as professions from './responses/professions' import * as files from './responses/files' import * as masteries from './responses/masteries' import * as mounts from './responses/mounts' +import * as raids from './responses/raids' export interface Schema extends BaseSchema { @@ -96,6 +97,8 @@ export interface Schema extends BaseSchema { Quaggans: quaggans.Schema_1970_01_01.Quaggan // Races Races: races.Schema_1970_01_01.Race + // Raid + Raid: raids.Schema_1970_01_01.Raid // Titles Titles: titles.Schema_1970_01_01.Title // Tokeninfo From 988a0eec68479fd1571a42ed8cc3e79e1ffc39f2 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 28 May 2023 21:31:17 +0200 Subject: [PATCH 54/72] Add mapchests response --- src/endpoints/schemas/responses/mapchests.ts | 7 +++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 src/endpoints/schemas/responses/mapchests.ts diff --git a/src/endpoints/schemas/responses/mapchests.ts b/src/endpoints/schemas/responses/mapchests.ts new file mode 100644 index 0000000..31978c2 --- /dev/null +++ b/src/endpoints/schemas/responses/mapchests.ts @@ -0,0 +1,7 @@ +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/mapchests} */ + export interface Mapchest { + /** The (API-specific) id of the map chest. */ + id: string + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index aef2941..0634a6c 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -31,6 +31,7 @@ import * as files from './responses/files' import * as masteries from './responses/masteries' import * as mounts from './responses/mounts' import * as raids from './responses/raids' +import * as mapchests from './responses/mapchests' export interface Schema extends BaseSchema { @@ -76,6 +77,8 @@ export interface Schema extends BaseSchema { Legends: legends.Schema_1970_01_01.Legend // Mailcarriers Mailcarriers: mailcarriers.Schema_1970_01_01.Mailcarrier + // Mapchests + Mapchests: mapchests.Schema_1970_01_01.Mapchest // Masteries Masteries: masteries.Schema_1970_01_01.Mastery // Mounts From 32250e99aee0326de671a11382b399b31cc71eab Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Mon, 29 May 2023 09:34:37 +0200 Subject: [PATCH 55/72] Add legendaryarmory response --- .../schemas/responses/legendaryarmory.ts | 18 ++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 21 insertions(+) create mode 100644 src/endpoints/schemas/responses/legendaryarmory.ts diff --git a/src/endpoints/schemas/responses/legendaryarmory.ts b/src/endpoints/schemas/responses/legendaryarmory.ts new file mode 100644 index 0000000..1da7892 --- /dev/null +++ b/src/endpoints/schemas/responses/legendaryarmory.ts @@ -0,0 +1,18 @@ +/** + * - 1: Armor items, Back items and most Trinkets (except the ring Conflux) + * - 2: Focus, Greatsword, Hammer, Harpoon, Longbow, Rifle, Scepter, Shield, Short bow, Speargun, Staff, Torch, Trident and Warhorn. Also applies to Conflux. + * - 4: Axe, Dagger, Mace, Pistol, Sword + * - 7: Rune + * - 8: Sigil + */ +type Quantity = 1 | 2 | 4 | 7 | 8 + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/legendaryarmory} */ + export interface Legendaryarmory { + /** The item id of the Legendary Armor item. */ + id: number + /** The maximum quantity of Legendary Armory items that can be stored on an account. */ + max_count: Quantity + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 0634a6c..b981de5 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -32,6 +32,7 @@ import * as masteries from './responses/masteries' import * as mounts from './responses/mounts' import * as raids from './responses/raids' import * as mapchests from './responses/mapchests' +import * as legendaryarmory from './responses/legendaryarmory' export interface Schema extends BaseSchema { @@ -73,6 +74,8 @@ export interface Schema extends BaseSchema { // Continents Continents: continents.Schema_1970_01_01.Continent Floor: continents.Schema_1970_01_01.Floor + // Legendary Armory + LegendaryArmory: legendaryarmory.Schema_1970_01_01.Legendaryarmory // Legends Legends: legends.Schema_1970_01_01.Legend // Mailcarriers From cb620101eba30a96cdbbd8415e3b68022d8ad40a Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Mon, 29 May 2023 09:37:18 +0200 Subject: [PATCH 56/72] Move cats and nodes to home --- src/endpoints/schemas/schema_1970_01_01.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index b981de5..76787fc 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -44,8 +44,9 @@ export interface Schema extends BaseSchema { Group: achievements.Schema_1970_01_01.Group // Build Build: build.Schema_1970_01_01.Build - // Cats + // Home Cats: cats.Schema_1970_01_01.Cat + Nodes: nodes.Schema_1970_01_01.Nodes // Backstory Answers: backstory.Schema_1970_01_01.Answer Questions: backstory.Schema_1970_01_01.Question @@ -89,8 +90,6 @@ export interface Schema extends BaseSchema { MountSkin: mounts.Schema_1970_01_01.Skin // Minis Minis: minis.Schema_1970_01_01.Mini - // Nodes - Nodes: nodes.Schema_1970_01_01.Nodes // Novelties Novelties: novelties.Schema_1970_01_01.Novelty // Outfits From 1f8dd214007f6b985c03ae2be74357a52ad6717b Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Mon, 29 May 2023 09:39:42 +0200 Subject: [PATCH 57/72] Add worldbosses response --- src/endpoints/schemas/responses/worldbosses.ts | 7 +++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 src/endpoints/schemas/responses/worldbosses.ts diff --git a/src/endpoints/schemas/responses/worldbosses.ts b/src/endpoints/schemas/responses/worldbosses.ts new file mode 100644 index 0000000..5471a3a --- /dev/null +++ b/src/endpoints/schemas/responses/worldbosses.ts @@ -0,0 +1,7 @@ +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/worldbosses} */ + export interface Worldboss { + /** The (API-specific) id of the world boss. */ + id: string + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 76787fc..58b9085 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -33,6 +33,7 @@ import * as mounts from './responses/mounts' import * as raids from './responses/raids' import * as mapchests from './responses/mapchests' import * as legendaryarmory from './responses/legendaryarmory' +import * as worldbosses from './responses/worldbosses' export interface Schema extends BaseSchema { @@ -112,4 +113,6 @@ export interface Schema extends BaseSchema { Traits: traits.Schema_1970_01_01.Trait // Skins Skins: skins.Schema_1970_01_01.Skin + // Worldbosses + Worldbosses: worldbosses.Schema_1970_01_01.Worldboss } From 8f9a89602f88f7451c6f24ab0e025767d55c2b91 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Mon, 29 May 2023 09:45:32 +0200 Subject: [PATCH 58/72] Add world response --- src/endpoints/schemas/responses/worlds.ts | 18 ++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 21 insertions(+) create mode 100644 src/endpoints/schemas/responses/worlds.ts diff --git a/src/endpoints/schemas/responses/worlds.ts b/src/endpoints/schemas/responses/worlds.ts new file mode 100644 index 0000000..aea79c8 --- /dev/null +++ b/src/endpoints/schemas/responses/worlds.ts @@ -0,0 +1,18 @@ +type Population = 'Low' | 'Medium' | 'High' | 'VeryHigh' | 'Full' + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/worlds} */ + export interface World { + /** The world id. + * + * The first digit of the id indicates the world's region. 1 is North America, 2 is Europe. + * + * The second digit of the id currently correlates with the world's assigned language: 1 means French, 2 means German, and 3 means Spanish. + */ + id: number + /** The world name. */ + name: string + /** The world population level. One of: Low, Medium, High, VeryHigh, Full */ + population: string + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 58b9085..8eb2905 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -34,6 +34,7 @@ import * as raids from './responses/raids' import * as mapchests from './responses/mapchests' import * as legendaryarmory from './responses/legendaryarmory' import * as worldbosses from './responses/worldbosses' +import * as worlds from './responses/worlds' export interface Schema extends BaseSchema { @@ -113,6 +114,8 @@ export interface Schema extends BaseSchema { Traits: traits.Schema_1970_01_01.Trait // Skins Skins: skins.Schema_1970_01_01.Skin + // Worlds + Worlds: worlds.Schema_1970_01_01.World // Worldbosses Worldbosses: worldbosses.Schema_1970_01_01.Worldboss } From 43662d8ea224d17b8618b6fc373c87bf82db76f6 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Mon, 29 May 2023 09:48:38 +0200 Subject: [PATCH 59/72] Add quest response --- src/endpoints/schemas/responses/quests.ts | 22 ++++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 25 insertions(+) create mode 100644 src/endpoints/schemas/responses/quests.ts diff --git a/src/endpoints/schemas/responses/quests.ts b/src/endpoints/schemas/responses/quests.ts new file mode 100644 index 0000000..fb81e14 --- /dev/null +++ b/src/endpoints/schemas/responses/quests.ts @@ -0,0 +1,22 @@ +interface Goal { + /** The text displayed for the quest step if it is active. */ + active: string + /** The text displayed for the quest step if it is complete. */ + complete: string +} + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/quests} */ + export interface Quest { + /** The id of the quest. */ + id: number + /** The name of the quest. */ + name: string + /** The minimum level required for a character to begin this quest. */ + level: number + /** The id for the story; resolvable against v2/stories. */ + story: string + /** An array of goal objects providing details about the goals for this quest. */ + goals: Goal[] + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 8eb2905..43f2814 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -35,6 +35,7 @@ import * as mapchests from './responses/mapchests' import * as legendaryarmory from './responses/legendaryarmory' import * as worldbosses from './responses/worldbosses' import * as worlds from './responses/worlds' +import * as quests from './responses/quests' export interface Schema extends BaseSchema { @@ -77,6 +78,8 @@ export interface Schema extends BaseSchema { // Continents Continents: continents.Schema_1970_01_01.Continent Floor: continents.Schema_1970_01_01.Floor + // Quests + Quests: quests.Schema_1970_01_01.Quest // Legendary Armory LegendaryArmory: legendaryarmory.Schema_1970_01_01.Legendaryarmory // Legends From 287ad27e86f97eac6924a6cd189f5fa3bc7c6953 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Mon, 29 May 2023 09:56:04 +0200 Subject: [PATCH 60/72] Add stories response --- src/endpoints/schemas/responses/stories.ts | 33 ++++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 ++ 2 files changed, 36 insertions(+) create mode 100644 src/endpoints/schemas/responses/stories.ts diff --git a/src/endpoints/schemas/responses/stories.ts b/src/endpoints/schemas/responses/stories.ts new file mode 100644 index 0000000..1443a21 --- /dev/null +++ b/src/endpoints/schemas/responses/stories.ts @@ -0,0 +1,33 @@ +import { Race } from "../../../types" + +// FIXME: are there more? +type StoryFlag = 'RequiresUnlock' + +interface Chapter { + /** The name of the chapter. */ + name: string +} + +export namespace Schema_1970_01_01 { + /** @link {https://wiki.guildwars2.com/wiki/API:2/stories} */ + export interface Story { + /** The id of the story. */ + id: number + /** The id for the story season; resolvable against v2/stories/seasons. */ + season: string + /** The name of the story. */ + name: string + /** The description of the story. */ + description: string + /** The (in-game, not real-world) date of the story. */ + timeline: string + /** The minimum level required for a character to begin this story. */ + level: number + /** The order in which this story is displayed in the Story Journal. */ + order: number + /** An array of chapter objects providing details about the chapters for this story. */ + chapters: Chapter[] + races?: Race[] + flags?: StoryFlag[] + } +} diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 43f2814..7b880ea 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -36,6 +36,7 @@ import * as legendaryarmory from './responses/legendaryarmory' import * as worldbosses from './responses/worldbosses' import * as worlds from './responses/worlds' import * as quests from './responses/quests' +import * as stories from './responses/stories' export interface Schema extends BaseSchema { @@ -109,6 +110,8 @@ export interface Schema extends BaseSchema { Races: races.Schema_1970_01_01.Race // Raid Raid: raids.Schema_1970_01_01.Raid + // Stories + Stories: stories.Schema_1970_01_01.Story // Titles Titles: titles.Schema_1970_01_01.Title // Tokeninfo From fbd115ade29809a314ba8162fb8e8aa53504897e Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 3 Jun 2023 14:07:51 +0200 Subject: [PATCH 61/72] Add account response --- src/endpoints/schemas/responses/account.ts | 58 ++++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 ++ src/endpoints/schemas/schema_2019_02_21.ts | 5 +- src/endpoints/schemas/schema_2019_12_19.ts | 4 +- 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 src/endpoints/schemas/responses/account.ts diff --git a/src/endpoints/schemas/responses/account.ts b/src/endpoints/schemas/responses/account.ts new file mode 100644 index 0000000..59a5a2a --- /dev/null +++ b/src/endpoints/schemas/responses/account.ts @@ -0,0 +1,58 @@ +import { ISO8601 } from "../../../types" + +/** + * - `None` – should probably never happen + * - `PlayForFree` – without any other flags, this identifies an account which has not yet purchased the game. (This flag does however also appear on accounts who have purchased the base game or any of the expansions) + * – `GuildWars2` – has purchased the base game + * - `HeartOfThorns` – has purchased Heart of Thorns, accounts that recieve Heart of Thorns by purchasing Path of Fire will not have this flag set. + * - `PathOfFire` – has purchased Path of Fire, this flag also implies that the account has access to Heart of Thorns. + * - `EndOfDragons` – has purchased End of Dragons + */ +type Access = 'None' | 'PlayForFree' | 'GuildWars2' | 'HeartOfThorns' | 'PathOfFire' | 'EndOfDragons' + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/account} */ + export interface Account { + /** The unique persistent account GUID. */ + id: string + /** The age of the account in seconds. */ + age: number + /** The unique account name with numerical suffix. It is possible that the name change. Do not rely on the name, use id instead. */ + name: string + /** The id of the home world the account is assigned to. Can be resolved against /v2/worlds. */ + world: number + /** A list of guilds assigned to the given account. */ + guilds: Array + /** A list of guilds the account is leader of. Requires the additional guilds scope. */ + guild_leader: Array + /** An ISO-8601 standard timestamp of when the account was created. */ + created: string + /** A list of what content this account has access to. Possible values: */ + access: Access[] + /** True if the player has bought a commander tag. */ + commander: boolean + /** The account's personal fractal reward level. Requires the additional progression scope. */ + fractal_level: number + /** The daily AP the account has. Requires the additional progression scope. */ + daily_ap: number + /** The monthly AP the account has. Requires the additional progression scope. */ + monthly_ap: number + /** The account's personal wvw rank. Requires the additional progression scope. */ + wvw_rank: number + } +} + +export namespace Schema_2019_02_21 { + /** {@link https://wiki.guildwars2.com/API:2/account} */ + export interface Account extends Schema_1970_01_01.Account { + /** An ISO-8601 standard timestamp of when the account information last changed as perceived by the API. This field is only present when a Schema version of 2019-02-21T00:00:00Z or later is requested. */ + last_modified: ISO8601 + } +} + +export namespace Schema_2019_12_19 { + export interface Account extends Schema_2019_02_21.Account { + /** The amount of build storage slot an account has unlocked. Requires the additional builds scope. This field is only present when a Schema version of 2019-12-19T00:00:00.000Z or later is requested. */ + build_storage_slots: number + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 7b880ea..113fd5d 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -37,9 +37,12 @@ import * as worldbosses from './responses/worldbosses' import * as worlds from './responses/worlds' import * as quests from './responses/quests' import * as stories from './responses/stories' +import * as account from './responses/account' export interface Schema extends BaseSchema { + // Account + Account: account.Schema_1970_01_01.Account // Achievements Daily: achievements.Schema_1970_01_01.Daily Dailies: achievements.Schema_1970_01_01.Dailies diff --git a/src/endpoints/schemas/schema_2019_02_21.ts b/src/endpoints/schemas/schema_2019_02_21.ts index 8403b07..2580555 100644 --- a/src/endpoints/schemas/schema_2019_02_21.ts +++ b/src/endpoints/schemas/schema_2019_02_21.ts @@ -1,5 +1,6 @@ import { Schema as BaseSchema } from './schema_1970_01_01' +import * as account from './responses/account' -export interface Schema extends BaseSchema { - +export interface Schema extends Omit { + Account: account.Schema_2019_02_21.Account } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_2019_12_19.ts b/src/endpoints/schemas/schema_2019_12_19.ts index 7a2d269..ac988c4 100644 --- a/src/endpoints/schemas/schema_2019_12_19.ts +++ b/src/endpoints/schemas/schema_2019_12_19.ts @@ -1,8 +1,10 @@ import { Schema as BaseSchema } from './schema_2019_05_22' +import * as account from './responses/account' import * as legends from './responses/legends' import * as professions from './responses/professions' -export interface Schema extends Omit { +export interface Schema extends Omit { + Account: account.Schema_2019_12_19.Account Legends: legends.Schema_2019_12_19.Legend Professions: professions.Schema_2019_12_19.Profession } \ No newline at end of file From 6ea5c27876dc784129f459b277a1c9ca847a58f4 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 3 Jun 2023 14:10:43 +0200 Subject: [PATCH 62/72] Add specializaations response --- .../schemas/responses/specializations.ts | 23 +++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/endpoints/schemas/responses/specializations.ts diff --git a/src/endpoints/schemas/responses/specializations.ts b/src/endpoints/schemas/responses/specializations.ts new file mode 100644 index 0000000..7c3a09b --- /dev/null +++ b/src/endpoints/schemas/responses/specializations.ts @@ -0,0 +1,23 @@ +import { URL } from "../../../types" + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/specializations} */ + export interface Specialization { + /** The specialization's ID. */ + id: number + /** The name of the specialization. */ + name: string + /** The profession that this specialization belongs to. */ + profession: string + /** true if this specialization is an Elite specialization, false otherwise. */ + elite: boolean + /** A URL to an icon of the specialization. */ + icon: URL + /** A URL to the background image of the specialization. */ + background: URL + /** Contains a list of IDs specifying the minor traits in the specialization. */ + minor_traits: Array + /** Contains a list of IDs specifying the major traits in the specialization. */ + major_traits: Array + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 113fd5d..5476c57 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -38,7 +38,7 @@ import * as worlds from './responses/worlds' import * as quests from './responses/quests' import * as stories from './responses/stories' import * as account from './responses/account' - +import * as specializations from './responses/specializations' export interface Schema extends BaseSchema { // Account @@ -113,6 +113,8 @@ export interface Schema extends BaseSchema { Races: races.Schema_1970_01_01.Race // Raid Raid: raids.Schema_1970_01_01.Raid + // Specializations + Specializations: specializations.Schema_1970_01_01.Specialization // Stories Stories: stories.Schema_1970_01_01.Story // Titles From 7647917b5d1eefa77187b8644063d4716eeea3bc Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 3 Jun 2023 14:12:54 +0200 Subject: [PATCH 63/72] Add materials responses --- src/endpoints/schemas/responses/materials.ts | 13 +++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ 2 files changed, 16 insertions(+) create mode 100644 src/endpoints/schemas/responses/materials.ts diff --git a/src/endpoints/schemas/responses/materials.ts b/src/endpoints/schemas/responses/materials.ts new file mode 100644 index 0000000..8a0ebb4 --- /dev/null +++ b/src/endpoints/schemas/responses/materials.ts @@ -0,0 +1,13 @@ +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/materials} */ + export interface Material { + /** The category id. */ + id: number + /** The category name. */ + name: string + /** The ids of the items in this category. */ + items: Array + /** The order in which the category appears in the material storage. */ + order: number + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 5476c57..e26ea34 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -39,6 +39,7 @@ import * as quests from './responses/quests' import * as stories from './responses/stories' import * as account from './responses/account' import * as specializations from './responses/specializations' +import * as materials from './responses/materials' export interface Schema extends BaseSchema { // Account @@ -94,6 +95,8 @@ export interface Schema extends BaseSchema { Mapchests: mapchests.Schema_1970_01_01.Mapchest // Masteries Masteries: masteries.Schema_1970_01_01.Mastery + // Materials + Materials: materials.Schema_1970_01_01.Material // Mounts MountType: mounts.Schema_1970_01_01.Type MountSkin: mounts.Schema_1970_01_01.Skin From 9a36f2155864b1d58a10a71ef62975456862b8ce Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Fri, 23 Jun 2023 22:55:12 +0200 Subject: [PATCH 64/72] Add response for guild enpoints --- src/endpoints/schemas/responses/guilds.ts | 341 +++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 13 + 2 files changed, 354 insertions(+) create mode 100644 src/endpoints/schemas/responses/guilds.ts diff --git a/src/endpoints/schemas/responses/guilds.ts b/src/endpoints/schemas/responses/guilds.ts new file mode 100644 index 0000000..9bc3107 --- /dev/null +++ b/src/endpoints/schemas/responses/guilds.ts @@ -0,0 +1,341 @@ +// FIXME: probably break this up into multiple files + +import { ISO8601 } from "../../../types" + +type GuildFlag = 'FlipBackgroundHorizontal' | 'FlipBackgroundVertical' +type StashOperation = 'deposit' | 'withdraw' | 'move' +type UpgradeAction = 'queued' | 'cancelled' | 'completed' | 'sped_up' +// cba, FIXME? +type Permission = string + + +// EMBLEM STUFF +interface EmblemLayer { + /** The layer id, to be resolved against /v2/emblem/backgrounds or /v2/emblem/foregrounds respectively */ + id: number + /** An array of numbers containing the id of each color used. */ + colors: number[] +} + +interface Emblem { + /** An object containing information of the background of the guild emblem. */ + background: EmblemLayer + /** An object containing information of the foreground of the guild emblem. */ + foreground: EmblemLayer + /** An array containing the manipulations applied to the logo. */ + flags: GuildFlag[] +} + +// LOG STUFF +/** {@link https://wiki.guildwars2.com/API:2/guild/:id/log} */ +export interface BaseLog { + /** An ID to uniquely identify the log entry within the scope of the guild. Not globally unique. */ + id: number + /** ISO-8601 standard timestamp for when the log entry was created. */ + time: ISO8601 + /** The account name of the guild member who generated this log entry. */ + user?: string + /** The type of log entry. Additional fields are given depending on the type. */ + type: T +} + +/** user has been invited to the guild. */ +interface InvitedLogDetails { + /** Account name of the guild member which invited the player. */ + invited_by: string +} + +/** user has been kicked from the guild. */ +interface KickLogDetails { + /** Account name of the guild member which kicked the player. */ + kicked_by: string +} + +/** Rank for user has been changed. */ +interface RankChangeLogDetails { + /** Account name of the guild member which changed the player rank. */ + changed_by: string + /** Old rank name. */ + old_rank: string + /** New rank name. */ + new_rank: string +} + +/** A guild member has deposited an item into the guild's treasury. */ +interface TreasuryLogDetails { + /** The item ID that was deposited into the treasury. */ + item_id: number + /** How many of the specified item was deposited. */ + count: number +} + +/** - A guild member has deposited/withdrawn an item into the guild stash. */ +interface StashLogDetails { + operation: StashOperation + /** The item ID that was deposited into the treasury. */ + item_id: number + /** How many of the specified item was deposited. */ + count: number + /** How many coins (in copper) were deposited. */ + coins: number +} + +/** A guild member has changed the guild's MOTD. */ +interface MOTDLogDetails { + /** The new MOTD. */ + motd: string +} + +/** A guild member has interacted with a guild upgrade. Additional fields include: */ +interface UpgradeLogDetails { + /** The type of interaction had. */ + action: UpgradeAction + /** Having this action will also generate a new count field indicating how many upgrades were added. */ + completed: any + /** The upgrade ID which was completed. */ + upgrade_id: number + /** May be added if the upgrade was created through a scribe station by a scribe. */ + recipe_id: number +} + +type JoinedLog = BaseLog<'joined'> +type InvitedLog = BaseLog<'invited'> & InvitedLogDetails +type KickLog = BaseLog<'kick'> & KickLogDetails +type RankChangeLog = BaseLog<'rank_change'> & RankChangeLogDetails +type TreasuryLog = BaseLog<'treasury'> & TreasuryLogDetails +type StashLog = BaseLog<'stash'> & StashLogDetails +type MOTDLog = BaseLog<'motd'> & MOTDLogDetails +type UpgradeLog = BaseLog<'upgrade'> & UpgradeLogDetails + +// STASH STUFF +interface InventoryEntry { + /** ID of the item in this slot. */ + id: number + /** Amount of items in this slot. */ + count: number +} + +// TEAM STUFF +interface TeamMember { + /** should match up with /v2/guild/:id/members. */ + name: string + /** "Captain" or "Member". */ + role: 'Captain' | 'Member' +} + +interface Season { + id: string + wins: number + losses: number + rating: number +} + +// TREASURY STUFF +interface NeededBy { + /** The ID of the upgrade needing this item. */ + upgrade_id: number + /** The total amount the upgrade needs for this item. */ + count: number +} + +// UPGRADE STUFF +interface UpgradeCost { + /** The type of cost. */ + type: 'Item' | 'Collectible' | 'Currency' | 'Coins' + /** The name of the cost. */ + name: string + /** The amount needed. */ + count: number + /** The id of the item, if applicable, resolvable against v2/items. */ + item_id?: number +} + + +/** {@link https://wiki.guildwars2.com/API:2/guild/upgrades} */ +interface BaseUpgrade { + /** The upgrade id. */ + id: number + /** The name of the upgrade. */ + name: string + /** The guild upgrade description. */ + description: string + /** The upgrade type. Some upgrade types will add additional fields to describe them further. Possible values: + * + * - "AccumulatingCurrency": Used for mine capacity upgrades. + * - "BankBag": Used for guild bank upgrades. + * - "Boost": Used for permanent guild buffs such as waypoint cost reduction. + * - "Claimable": Used for guild WvW tactics. + * - "Consumable": Used for banners and guild siege. + * - "Decoration": Used for decorations that must be crafted by a Scribe. + * - "GuildHall": Used for claiming a Guild Hall. + * - "Hub": Used for the Guild Initiative office unlock. + * - "Queue": Used for Workshop Restoration 1. + * - "Unlock": Used for permanent unlocks, such as merchants and arena decorations. + */ + type: T + /** A URL pointing to an icon for the upgrade. */ + icon: string + /** The time it takes to build the upgrade. */ + build_time: number + /** The prerequisite level the guild must be at to build the upgrade. */ + required_level: number + /** The amount of guild experience that will be awarded upon building the upgrade. */ + experience: number + /** An array of upgrade IDs that must be completed before this can be built. */ + prerequisites: Array + /** An array of objects describing the upgrade's cost. Each object in the array has the following properties: */ + costs: Array + +} + +interface BankBagUpgradeDetails { + /** The maximum item slots of the guild bank tab. */ + bag_max_items: number + /** The maximum amount of coins that can be stored in the bank tab. */ + bag_max_coins: number +} + +type BankBagUpgrade = BaseUpgrade<'BankBag'> & BankBagUpgradeDetails +type AccumulatingCurrencyUpgrade = BaseUpgrade<'AccumulatingCurrency'> +type BoostUpgrade = BaseUpgrade<'Boost'> +type ClaimableUpgrade = BaseUpgrade<'Claimable'> +type ConsumableUpgrade = BaseUpgrade<'Consumable'> +type DecorationUpgrade = BaseUpgrade<'Decoration'> +type GuildHallUpgrade = BaseUpgrade<'GuildHall'> +type HubUpgrade = BaseUpgrade<'Hub'> +type QueueUpgrade = BaseUpgrade<'Queue'> +type UnlockUpgrade = BaseUpgrade<'Unlock'> + + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/guild/:id} */ + export interface Guild { + /** The unique guild id. */ + id: string + /** The guild's name. */ + name: string + /** The 2 to 4 letter guild tag representing the guild. */ + tag: string + /** The guild emblem. */ + emblem: Emblem + /** The current level of the guild. */ + level: number + /** The message of the day written out in a single string. */ + motd: string + /** The guild's current influence. */ + influence: number + /** The guild's current aetherium level. */ + aetherium: string + /** The guild's current level of favor. */ + favor: number + /** The number of People currently in the Guild. */ + member_count: number + /** The maximum number of People that can be in the Guild. (see Guild#Membership) */ + member_capacity: number + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/guild/:id/log} */ + export type Log = JoinedLog | InvitedLog | KickLog | RankChangeLog | TreasuryLog | StashLog | MOTDLog | UpgradeLog + + + /** {@link https://wiki.guildwars2.com/API:2/guild/:id/members} */ + export interface Member { + /** The account name of the member. */ + name: string + /** The guild rank of the member. (See /v2/guild/:id/ranks.) */ + rank: string + /** The time and date the member joined the guild (ISO-8601 standard). May also be null -- the join date was not tracked before around March 19th, 2013. */ + joined: ISO8601 + } + + /** {@link https://wiki.guildwars2.com/API:2/guild/:id/ranks} */ + export interface Rank { + /** The ID and name of the rank. */ + id: string + /** A number given to each rank to specify how they should be sorted, lowest being the first and highest being the last. */ + order: number + /** An array of permission ids from /v2/guild/permissions that have been given to this rank. */ + permissions: Array + /** A URL pointing to the image currently assigned to this rank. */ + icon: string + } + + + + /** {@link https://wiki.guildwars2.com/API:2/guild/:id/stash} */ + export interface Stash { + /** ID of the guild upgrade that granted access to this section of the guild vault. */ + upgrade_id: number + /** The number of slots in this section of the guild vault. */ + size: number + /** The number of coins deposited in this section of the guild vault. */ + coins: number + /** The description set for this section of the guild's vault. */ + note: string + /** An array of objects describing the items in the guild stash of exactly size length. Each object either contains the following properties if an item is present, or is null if the slot is empty: */ + inventory: Array + } + + /** {@link https://wiki.guildwars2.com/API:2/guild/:id/storage} */ + export interface Storage { + /** ID of the guild consumable. */ + id: number + /** Amount of the consumable in storage. */ + count: number + } + + /** {@link https://wiki.guildwars2.com/API:2/guild/:id/teams} */ + export interface Team { + /** the team ID, only unique within a guild. */ + id: number + members: TeamMember[] + /** matches the format of /v2/pvp/stats. */ + aggregate: object // FIXME: infer + /** matches the format of /v2/pvp/stats. */ + ladders: object // FIXME: infer + /** matches the format of /v2/pvp/games with profession omitted. */ + games: object[] // FIXME: infer + /** Amount of items in this slot. */ + seasons: Season[] + } + + + /** {@link https://wiki.guildwars2.com/API:2/guild/:id/treasury} */ + export interface Treasury { + /** The item's ID. */ + item_id: number + /** How many of the item are currently in the treasury. */ + count: number + /** An array of objects describing which currently in-progress upgrades are needing this item. Each object has the following properties: */ + needed_by: Array + + } + + // FIXME: do we need the https://wiki.guildwars2.com/wiki/API:2/guild/:id/upgrades one? + /** {@link https://wiki.guildwars2.com/wiki/API:2/guild/upgrades} */ + export type Upgrade = BankBagUpgrade + | AccumulatingCurrencyUpgrade + | BoostUpgrade + | ClaimableUpgrade + | ConsumableUpgrade + | DecorationUpgrade + | GuildHallUpgrade + | HubUpgrade + | QueueUpgrade + | UnlockUpgrade + + /** {@link https://wiki.guildwars2.com/API:2/guild/permissions} */ + export interface Permission { + /** The permission id. */ + id: string + /** The name of the permission. */ + name: string + /** The description of the permission. */ + description: string + } + + /** {@link https://wiki.guildwars2.com/API:2/guild/search} */ + type Search = string[] + + +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index e26ea34..f276397 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -40,6 +40,7 @@ import * as stories from './responses/stories' import * as account from './responses/account' import * as specializations from './responses/specializations' import * as materials from './responses/materials' +import * as guilds from './responses/guilds' export interface Schema extends BaseSchema { // Account @@ -80,6 +81,18 @@ export interface Schema extends BaseSchema { Finishers: finishers.Schema_1970_01_01.Finisher // Gliders Gliders: gliders.Schema_1970_01_01.Glider + // Guilds + Guilds: guilds.Schema_1970_01_01.Guild + Logs: guilds.Schema_1970_01_01.Log + Members: guilds.Schema_1970_01_01.Member + Ranks: guilds.Schema_1970_01_01.Rank + Stash: guilds.Schema_1970_01_01.Stash + Storage: guilds.Schema_1970_01_01.Storage + Team: guilds.Schema_1970_01_01.Team + Treasury: guilds.Schema_1970_01_01.Treasury + Upgrades: guilds.Schema_1970_01_01.Upgrade + Permissions: guilds.Schema_1970_01_01.Permission + Search: guilds.Schema_1970_01_01.Search // Continents Continents: continents.Schema_1970_01_01.Continent Floor: continents.Schema_1970_01_01.Floor From 682ba2dfae8d93d69024e98420a835f9265fd94f Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 24 Jun 2023 20:34:57 +0200 Subject: [PATCH 65/72] Add some of characters response --- src/endpoints/schemas/responses/characters.ts | 230 ++++++++++++++++++ src/endpoints/schemas/responses/guilds.ts | 2 +- src/endpoints/schemas/schema_1970_01_01.ts | 3 + src/endpoints/schemas/schema_2019_12_19.ts | 4 +- src/types.ts | 3 + 5 files changed, 240 insertions(+), 2 deletions(-) create mode 100644 src/endpoints/schemas/responses/characters.ts diff --git a/src/endpoints/schemas/responses/characters.ts b/src/endpoints/schemas/responses/characters.ts new file mode 100644 index 0000000..7dafb0f --- /dev/null +++ b/src/endpoints/schemas/responses/characters.ts @@ -0,0 +1,230 @@ +import { Race, Gender, Profession, ISO8601, Discipline, EquipmentSlot } from "../../../types" + +type WeaponAttribute = 'AgonyResistance' | 'BoonDuration' | 'ConditionDamage' | 'ConditionDuration' | 'CritDamage' | 'Healing' | 'Power' | 'Precision' | 'Toughness' | 'Vitality' + +// BUILDTABS +interface BuildSpecialization { + /** The specialization id or null if none is selected. Resolvable against /v2/specializations. */ + id: number + /** Three trait ids or null in places where none is selected. Resolvable against /v2/traits. */ + traits: number[] +} + +interface BuildSkills { + /** The id of the heal skill or null if none is selected. */ + heal: number + /** Three utility skill ids or null in places where none is selected. */ + utilities: number[] + /** The id of the elite skill or null if none is selected. */ + elite: number +} + +interface BuildPets { + /** Containers the two pet ids the ranger has equipped for terrestrial combat. */ + terrestrial: [number, number] + /** Containers the two pet ids the ranger has equipped for aquaticcombat. */ + aquatic: [number, number] +} + +interface Build { + /** The name given to the build. */ + name: string + /** The characters profession. Resolvable against /v2/professions. */ + profession: string + /** Three objects providing information about the characters selected specializations. */ + specializations: [BuildSpecialization, BuildSpecialization, BuildSpecialization] + /** Contains information about the characters selected skills. All values may be resolved against /v2/skills. */ + skills: BuildSkills + /** Contains information about the characters selected underwater skills. The structure is the same as the one of skills above. */ + aquatic_skills: BuildSkills + /** Included for revenants only. Two legend ids or null in places where none is selected. Resolvable against /v2/legends. */ + legends?: [string | null, string | null] + /** Included for revenants only. The structure is the same as the one of legends above. */ + aquatic_legends?: [string | null, string | null] + /** Included for rangers only. Containers information about the characters selected pets. Resolvable against /v2/pets. */ + pets: BuildPets +} + +// EQUIPMENT +interface EquipmentAttributes { + /** Shows the amount of power given */ + Power?: number + /** Shows the amount of Precision given */ + Precision?: number + /** Shows the amount of Toughness given */ + Toughness?: number + /** Shows the amount of Vitality given */ + Vitality?: number + /** Shows the amount of Condition Damage given */ + Damage?: number + /** Shows the amount of Condition Duration given */ + Duration?: number + /** Shows the amount of Healing Power given */ + Healing?: number + /** Shows the amount of Boon Duration given */ + BoonDuration?: number +} + +interface EquipmentStats { + /** The itemstat id, can be resolved against /v2/itemstats */ + id: number + /** Contains a summary of the stats on the item. */ + attributes: EquipmentAttributes + +} + +export namespace Schema_1970_01_01 { + // CORE STUFF + /** {@link https://wiki.guildwars2.com/wiki/API:2/characters/:id/core} */ + export interface Core { + /** The character's name. */ + name: string + /** The character's race. Possible values: */ + race: Race + /** The character's gender. Possible values: */ + gender: Gender + /** The character's profession. Possible values: */ + profession: Profession + /** The character's level. */ + level: number + /** The guild ID of the character's currently represented guild. */ + guild?: string + /** The amount of seconds this character was played. */ + age: number + /** An ISO-8601 standard timestamp of when the account information last changed as perceived by the API. This field is only present when a Schema version of 2019-02-21T00:00:00Z or later is requested. */ + last_modified: ISO8601 + /** ISO 8601 representation of the character's creation time. */ + created: ISO8601 + /** The amount of times this character has been defeated. */ + deaths: number + /** The currently selected title for the character. References /v2/titles. */ + title?: number + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/characters/:id/crafting} */ + export interface Crafting { + /** The name of the discipline. Possible values: */ + discipline: Discipline + /** The current crafting level for the given discipline and character */ + rating: number + /** Describes if the given discipline is currently active or not on the character. */ + active: boolean + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/characters/:id/buildtabs} */ + export interface BuildTabs { + /** The "id" of this tab. (The position at which it resides.) */ + tab: number + /** Whether or not this is the tab selected on the character currently. */ + is_active: boolean + /** Contains detailed information about the build. */ + build: Build + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/characters/:id/buildtabs} */ + export interface Equipment { + /** The item id, resolvable against /v2/items */ + id: number + /** The equipment slot in which the item is slotted. This value is optional on schema 2019-12-19T00:00:00.000Z or later, will be missing if equipment is in an inactive tab. Possible values: */ + slot: EquipmentSlot + /** returns an array of infusion item ids which can be resolved against /v2/items */ + infusions?: Array + /** returns an array of upgrade component item ids which can be resolved against /v2/items */ + upgrades?: Array + /** Skin id for the given equipment piece. Can be resolved against /v2/skins */ + skin?: number + /** Contains information on the stats chosen if the item offers an option for stats/prefix. */ + stats: EquipmentStats + /** describes which kind of binding the item has. Possible values: */ + binding?: 'Character' | 'Account' + /** The amount of charges remaining on the item. */ + charges?: number + /** Name of the character the item is bound to. */ + bound_to?: string + /** Array of selected dyes for the equipment piece. Values default to null if no dye is selected. Colors can be resolved against v2/colors */ + dyes: number[] + } + + export interface Character { + /** An array containing an entry for each crafting discipline the character has unlocked */ + crafting: Array + /** An array containing an object for each equipment tab the character has. */ + equipment_tabs: Array + /** An array containing an entry for each piece of equipment currently on the selected character. */ + equipment: Array + } + + + interface WeaponStats { + /** The id of the wepons stats. Resolvable against /v2/itemstats. */ + id: number + /** Contains the weapon attributes in the form of key value pairs with the key being the attribute name and the value itself. */ + attributes: {[key in WeaponAttribute]?: number} + } + + + export interface EquipmentTabDetails { + /** The item id of the equipment piece. Resolvable against /v2/items. */ + id: number + /** In which slot the equipment piece is equiped. Possible values: */ + slot: string + /** The skin id of the skin transmuted onto the equipment piece. Resolvable against /v2/skins. */ + skin?: number + /** The item ids of the upgrade components sloted in the weapon. Resolvable against /v2/items. */ + upgrades?: number[] + /** The item ids of the infusions sloted in the weapon. Resolvable against /v2/items. */ + infusions?: number[] + /** The binding of the item. Possible values: */ + binding?: 'Account' | 'Character' + /** The name of the character to which the item is bound. */ + bound_to?: string + /** Either Equipped or Armory. */ + location: 'Equipped' | 'Armory' + /** Four dye ids representing the dyes used in the dye slots of the equipment piece or null if a dye slot is unavailable for a piece. Resolvable against /v2/colors. */ + dyes?: number[] + /** Contains detailed information on the weapon stats. */ + stats?: WeaponStats + + } + + interface EquipmentPvP { + /** resolve id against v2/pvp/amulets. */ + amulet: number + /** resolve id against v2/items. */ + rune: number + /** resolve ids against v2/items. Will contain nulls for unequipped items. */ + sigils: number[] + } + + export interface EquipmentTabs { + /** The "id" of this tab. (The position at which it resides.) */ + tab: number + /** The name given to the equipment combination. */ + name: string + /** Whether or not this is the tab selected on the character currently. */ + is_active: boolean + /** Contains an object for each equiped piece of equipment. */ + equipment: EquipmentTabDetails[] + /** Contains the following key-value pairs: */ + equipment_pvp: EquipmentPvP + } +} + +export namespace Schema_2019_12_19 { + export interface Equipment extends Omit { + /** The unlock count of this item when location is LegendaryArmory. Available on schema 2019-12-19T00:00:00.000Z or later. */ + count: number + /** The equipment slot in which the item is slotted. This value is optional on schema 2019-12-19T00:00:00.000Z or later, will be missing if equipment is in an inactive tab. Possible values: */ + slot?: EquipmentSlot + /** describes where this item is stored. Available on schema 2019-12-19T00:00:00.000Z or later. Possible values: + * + * - "Equipped": equipped in the active tab. + * - "Armory": equipped in an inactive tabs. + * - "EquippedFromLegendaryArmor": if the item is stored in the account-wide legendary armory, but equipped in the active tab. + * - "LegendaryArmory": if the item is stored in the account-wide legendary armory, but equipped in an inactive tabs. + */ + location: 'Equipped' | 'Armory' | 'EquippedFromLegendaryArmory' | 'LegendaryArmory' + /** identifies which tabs this particular item is reused in. Available on schema 2019-12-19T00:00:00.000Z or later. */ + tabs: number[] + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/responses/guilds.ts b/src/endpoints/schemas/responses/guilds.ts index 9bc3107..b4bc822 100644 --- a/src/endpoints/schemas/responses/guilds.ts +++ b/src/endpoints/schemas/responses/guilds.ts @@ -335,7 +335,7 @@ export namespace Schema_1970_01_01 { } /** {@link https://wiki.guildwars2.com/API:2/guild/search} */ - type Search = string[] + export type Search = string[] } \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index f276397..59d9085 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -41,6 +41,7 @@ import * as account from './responses/account' import * as specializations from './responses/specializations' import * as materials from './responses/materials' import * as guilds from './responses/guilds' +import * as characters from './responses/characters' export interface Schema extends BaseSchema { // Account @@ -53,6 +54,8 @@ export interface Schema extends BaseSchema { Group: achievements.Schema_1970_01_01.Group // Build Build: build.Schema_1970_01_01.Build + // Character + Equipment: characters.Schema_1970_01_01.Equipment // Home Cats: cats.Schema_1970_01_01.Cat Nodes: nodes.Schema_1970_01_01.Nodes diff --git a/src/endpoints/schemas/schema_2019_12_19.ts b/src/endpoints/schemas/schema_2019_12_19.ts index ac988c4..79773df 100644 --- a/src/endpoints/schemas/schema_2019_12_19.ts +++ b/src/endpoints/schemas/schema_2019_12_19.ts @@ -2,9 +2,11 @@ import { Schema as BaseSchema } from './schema_2019_05_22' import * as account from './responses/account' import * as legends from './responses/legends' import * as professions from './responses/professions' +import * as characters from './responses/characters' -export interface Schema extends Omit { +export interface Schema extends Omit { Account: account.Schema_2019_12_19.Account Legends: legends.Schema_2019_12_19.Legend Professions: professions.Schema_2019_12_19.Profession + Equipment: characters.Schema_2019_12_19.Equipment } \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 50e0133..c672658 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,11 +4,14 @@ export type URL = string export type ISO8601 = string export type Language = 'en' | 'de' | 'es' | 'fr' +export type Gender = 'Male' | 'Female' export type Race = 'Human' | 'Norn' | 'Charr' | 'Sylvari' | 'Asura' export type Profession = 'Guardian' | 'Revenant' | 'Warrior' | 'Engineer' | 'Ranger' | 'Thief' | 'Elementalist' | 'Mesmer' | 'Necromancer' +export type Discipline = 'Armorsmith' | 'Artificer' | 'Chef' | 'Huntsman' | 'Jeweler' | 'Leatherworker' | 'Scribe' | 'Tailor' | 'Weaponsmith' export type Region = 'Tyria' | 'Maguuma' | 'Desert' | 'Tundra' export type Rarity = 'Junk' | 'Basic' | 'Fine' | 'Masterwork' | 'Rare' | 'Exotic' | 'Ascended' | 'Legendary' export type Weapon = 'Axe' | 'Dagger' | 'Mace' | 'Pistol' | 'Sword' | 'Scepter' | 'Focus' | 'Shield' | 'Torch' | 'Warhorn' | 'Greatsword' | 'Hammer' | 'Longbow' | 'Rifle' | 'Shortbow' | 'Staff' | 'Speargun' | 'Spear' | 'Trident' export type Attunement = 'Fire' | 'Water' | 'Wind' | 'Earth' export type WeaponSlot = 'Weapon_1' +export type EquipmentSlot = 'HelmAquatic' | 'Backpack' | 'Coat' | 'Boots' | 'Gloves' | 'Helm' | 'Leggings' | 'Shoulders' | 'Accessory1' | 'Accessory2' | 'Ring1' | 'Ring2' | 'Amulet' | 'WeaponAquaticA' | 'WeaponAquaticB' | 'WeaponA1' | 'WeaponA2' | 'WeaponB1' | 'WeaponB2' | 'Sickle' | 'Axe' | 'Pick' export type ColorMaterial = 'cloth' | 'metal' | 'leather' | 'fur' \ No newline at end of file From e4ecd2e93f20218bbf8bd444f3fcefdb5a2f1767 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 24 Jun 2023 21:20:25 +0200 Subject: [PATCH 66/72] Add missing characters endpoint responses --- src/endpoints/schemas/responses/characters.ts | 196 ++++++++++++---- src/endpoints/schemas/schema_1970_01_01.ts | 220 +++++++++--------- 2 files changed, 267 insertions(+), 149 deletions(-) diff --git a/src/endpoints/schemas/responses/characters.ts b/src/endpoints/schemas/responses/characters.ts index 7dafb0f..92ac3c2 100644 --- a/src/endpoints/schemas/responses/characters.ts +++ b/src/endpoints/schemas/responses/characters.ts @@ -1,6 +1,9 @@ +// FIXME: https://wiki.guildwars2.com/wiki/API:2/characters heropoints, quests, and sab missing + import { Race, Gender, Profession, ISO8601, Discipline, EquipmentSlot } from "../../../types" type WeaponAttribute = 'AgonyResistance' | 'BoonDuration' | 'ConditionDamage' | 'ConditionDuration' | 'CritDamage' | 'Healing' | 'Power' | 'Precision' | 'Toughness' | 'Vitality' +type Binding = 'Character' | 'Account' // BUILDTABS interface BuildSpecialization { @@ -46,7 +49,30 @@ interface Build { } // EQUIPMENT -interface EquipmentAttributes { + +interface EquipmentTabDetails { + /** The item id of the equipment piece. Resolvable against /v2/items. */ + id: number + /** In which slot the equipment piece is equiped. Possible values: */ + slot: string + /** The skin id of the skin transmuted onto the equipment piece. Resolvable against /v2/skins. */ + skin?: number + /** The item ids of the upgrade components sloted in the weapon. Resolvable against /v2/items. */ + upgrades?: number[] + /** The item ids of the infusions sloted in the weapon. Resolvable against /v2/items. */ + infusions?: number[] + /** The binding of the item. Possible values: */ + binding?: Binding + /** The name of the character to which the item is bound. */ + bound_to?: string + /** Either Equipped or Armory. */ + location: 'Equipped' | 'Armory' + /** Four dye ids representing the dyes used in the dye slots of the equipment piece or null if a dye slot is unavailable for a piece. Resolvable against /v2/colors. */ + dyes?: number[] + /** Contains detailed information on the weapon stats. */ + stats?: WeaponStats +} +interface ItemAttributes { /** Shows the amount of power given */ Power?: number /** Shows the amount of Precision given */ @@ -65,12 +91,88 @@ interface EquipmentAttributes { BoonDuration?: number } -interface EquipmentStats { +interface EquipmentPvP { + /** resolve id against v2/pvp/amulets. */ + amulet: number + /** resolve id against v2/items. */ + rune: number + /** resolve ids against v2/items. Will contain nulls for unequipped items. */ + sigils: number[] +} + +interface ItemStats { /** The itemstat id, can be resolved against /v2/itemstats */ id: number /** Contains a summary of the stats on the item. */ - attributes: EquipmentAttributes + attributes: ItemAttributes +} + +interface WeaponStats { + /** The id of the wepons stats. Resolvable against /v2/itemstats. */ + id: number + /** Contains the weapon attributes in the form of key value pairs with the key being the attribute name and the value itself. */ + attributes: {[key in WeaponAttribute]?: number} +} + +// INVENTORY (also EQUIPMENT?) +interface Item { + /** The item id which can be resolved against /v2/items */ + id: number + /** Amount of item in the stack. Minium of 1, maximum of 250. */ + count: number + /** The number of charges on an item. */ + charges: number + /** returns an array of infusion item ids which can be resolved against /v2/items */ + infusions: Array + /** returns an array of upgrade component item ids which can be resolved against /v2/items */ + upgrades: Array + /** Skin id for the given equipment piece. Can be resolved against /v2/skins */ + skin: number + /** Contains information on the stats chosen if the item offers an option for stats/prefix. */ + stats: ItemStats + /** Array of selected dyes for the equipment piece. Values default to null if no dye is selected. Colors can be resolved against v2/colors */ + dyes: number[] + /** describes which kind of binding the item has. */ + binding: Binding + /** Name of the character the item is bound to. */ + bound_to: string +} + +interface Bag { + /** The bag's item id which can be resolved against /v2/items */ + id: number + /** The amount of slots available with this bag. */ + size: number + /** Contains one object structure per item, object is null if no item is in the given bag slot. */ + inventory: Array +} + +// SKILLS TRAITS TRAINING +interface SkillSet { + /** contains the skill id for the heal skill, resolvable against /v2/skills. */ + heal: number + /** each integer corresponds to a skill id for the equipped utilities, resolvable against /v2/skills. */ + utilities: number[] + /** contains the skill id for the elite skill, resolvable against /v2/skills. */ + elite: number + /** each string corresponds to a Revenant legend, resolvable against /v2/legends. */ + legends?: number[] +} + +interface Traits { + /** Specialization id, can be resolved against /v2/specializations. */ + id: number + /** returns ids for each selected trait, can be resolved against /v2/traits. */ + traits: number[] +} +interface TrainingDetails { + /** Skill tree id, can be compared against the training section for each /v2/professions. */ + id: number + /** Shows how many hero points have been spent in this tree */ + spent: number + /** States whether or not the tree is fully trained. */ + done: boolean } export namespace Schema_1970_01_01 { @@ -134,9 +236,9 @@ export namespace Schema_1970_01_01 { /** Skin id for the given equipment piece. Can be resolved against /v2/skins */ skin?: number /** Contains information on the stats chosen if the item offers an option for stats/prefix. */ - stats: EquipmentStats + stats: ItemStats /** describes which kind of binding the item has. Possible values: */ - binding?: 'Character' | 'Account' + binding?: Binding /** The amount of charges remaining on the item. */ charges?: number /** Name of the character the item is bound to. */ @@ -145,6 +247,7 @@ export namespace Schema_1970_01_01 { dyes: number[] } + // FIXME: Whats this? export interface Character { /** An array containing an entry for each crafting discipline the character has unlocked */ crafting: Array @@ -155,46 +258,7 @@ export namespace Schema_1970_01_01 { } - interface WeaponStats { - /** The id of the wepons stats. Resolvable against /v2/itemstats. */ - id: number - /** Contains the weapon attributes in the form of key value pairs with the key being the attribute name and the value itself. */ - attributes: {[key in WeaponAttribute]?: number} - } - - - export interface EquipmentTabDetails { - /** The item id of the equipment piece. Resolvable against /v2/items. */ - id: number - /** In which slot the equipment piece is equiped. Possible values: */ - slot: string - /** The skin id of the skin transmuted onto the equipment piece. Resolvable against /v2/skins. */ - skin?: number - /** The item ids of the upgrade components sloted in the weapon. Resolvable against /v2/items. */ - upgrades?: number[] - /** The item ids of the infusions sloted in the weapon. Resolvable against /v2/items. */ - infusions?: number[] - /** The binding of the item. Possible values: */ - binding?: 'Account' | 'Character' - /** The name of the character to which the item is bound. */ - bound_to?: string - /** Either Equipped or Armory. */ - location: 'Equipped' | 'Armory' - /** Four dye ids representing the dyes used in the dye slots of the equipment piece or null if a dye slot is unavailable for a piece. Resolvable against /v2/colors. */ - dyes?: number[] - /** Contains detailed information on the weapon stats. */ - stats?: WeaponStats - - } - interface EquipmentPvP { - /** resolve id against v2/pvp/amulets. */ - amulet: number - /** resolve id against v2/items. */ - rune: number - /** resolve ids against v2/items. Will contain nulls for unequipped items. */ - sigils: number[] - } export interface EquipmentTabs { /** The "id" of this tab. (The position at which it resides.) */ @@ -208,6 +272,50 @@ export namespace Schema_1970_01_01 { /** Contains the following key-value pairs: */ equipment_pvp: EquipmentPvP } + + + /** {@link https://wiki.guildwars2.com/wiki/API:2/characters/:id/inventory} */ + export interface Inventory { + /** Contains one object structure per bag in the character's inventory */ + bags: Array + } + + /** {@link https://wiki.guildwars2.com/wiki/API:2/characters/:id/recipes} */ + export interface Recipe { + recipes: number[] + } + + /** {@link https://wiki.guildwars2.com/API:2/characters/:id/skills} */ + export interface Skills { + /** contains the pve, pvp, and wvw objects for the current utilities equipped. */ + skills: { + /** contains the information on each slotted utility for PvE */ + pve: SkillSet + /** contains the information on each slotted utility for PvP */ + pvp: SkillSet + /** contains the information on each slotted utility for WvW */ + wvw: SkillSet + } + } + + /** {@link https://wiki.guildwars2.com/API:2/characters/:id/specializations} */ + export interface Specializations { + /** contains the pve, pvp, and wvw objects for the current specializations and traits equipped. */ + specializations: { + /** contains the information on each slotted specialization and trait for PvE */ + pve: Array + /** contains the information on each slotted specialization and trait for PvP */ + pvp: Array + /** contains the information on each slotted specialization and trait for WvW */ + wvw: Array + } + } + + /** {@link https://wiki.guildwars2.com/API:2/characters/:id/training} */ + export interface Training { + /** contains objects for each skill tree trained */ + training: Array + } } export namespace Schema_2019_12_19 { diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 59d9085..49a88c7 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -1,151 +1,161 @@ import { Schema as BaseSchema } from './schema' -import * as backstory from './responses/backstory' -import * as achievements from './responses/achievements' -import * as build from './responses/build' -import * as cats from './responses/cats' -import * as currencies from './responses/currencies' -import * as commerce from './responses/commerce' -import * as dungeons from './responses/dungeons' -import * as finishers from './responses/finishers' -import * as gliders from './responses/gliders' -import * as continents from './responses/continents' -import * as colors from './responses/colors' -import * as dailycrafting from './responses/dailycrafting' -import * as emblems from './responses/emblems' -import * as legends from './responses/legends' -import * as mailcarriers from './responses/mailcarriers' -import * as minis from './responses/minis' -import * as skins from './responses/skins' -import * as titles from './responses/titles' -import * as tokeninfo from './responses/tokeninfo' -import * as nodes from './responses/nodes' -import * as traits from './responses/traits' -import * as races from './responses/races' -import * as quaggans from './responses/quaggans' -import * as novelties from './responses/novelties' -import * as outfits from './responses/outfits' -import * as pets from './responses/pets' -import * as professions from './responses/professions' -import * as files from './responses/files' -import * as masteries from './responses/masteries' -import * as mounts from './responses/mounts' -import * as raids from './responses/raids' -import * as mapchests from './responses/mapchests' -import * as legendaryarmory from './responses/legendaryarmory' -import * as worldbosses from './responses/worldbosses' -import * as worlds from './responses/worlds' -import * as quests from './responses/quests' -import * as stories from './responses/stories' -import * as account from './responses/account' -import * as specializations from './responses/specializations' -import * as materials from './responses/materials' -import * as guilds from './responses/guilds' -import * as characters from './responses/characters' +import { Schema_1970_01_01 as backstory } from './responses/backstory' +import { Schema_1970_01_01 as achievements } from './responses/achievements' +import { Schema_1970_01_01 as build } from './responses/build' +import { Schema_1970_01_01 as cats } from './responses/cats' +import { Schema_1970_01_01 as currencies } from './responses/currencies' +import { Schema_1970_01_01 as commerce } from './responses/commerce' +import { Schema_1970_01_01 as dungeons } from './responses/dungeons' +import { Schema_1970_01_01 as finishers } from './responses/finishers' +import { Schema_1970_01_01 as gliders } from './responses/gliders' +import { Schema_1970_01_01 as continents } from './responses/continents' +import { Schema_1970_01_01 as colors } from './responses/colors' +import { Schema_1970_01_01 as dailycrafting } from './responses/dailycrafting' +import { Schema_1970_01_01 as emblems } from './responses/emblems' +import { Schema_1970_01_01 as legends } from './responses/legends' +import { Schema_1970_01_01 as mailcarriers } from './responses/mailcarriers' +import { Schema_1970_01_01 as minis } from './responses/minis' +import { Schema_1970_01_01 as skins } from './responses/skins' +import { Schema_1970_01_01 as titles } from './responses/titles' +import { Schema_1970_01_01 as tokeninfo } from './responses/tokeninfo' +import { Schema_1970_01_01 as nodes } from './responses/nodes' +import { Schema_1970_01_01 as traits } from './responses/traits' +import { Schema_1970_01_01 as races } from './responses/races' +import { Schema_1970_01_01 as quaggans } from './responses/quaggans' +import { Schema_1970_01_01 as novelties } from './responses/novelties' +import { Schema_1970_01_01 as outfits } from './responses/outfits' +import { Schema_1970_01_01 as pets } from './responses/pets' +import { Schema_1970_01_01 as professions } from './responses/professions' +import { Schema_1970_01_01 as files } from './responses/files' +import { Schema_1970_01_01 as masteries } from './responses/masteries' +import { Schema_1970_01_01 as mounts } from './responses/mounts' +import { Schema_1970_01_01 as raids } from './responses/raids' +import { Schema_1970_01_01 as mapchests } from './responses/mapchests' +import { Schema_1970_01_01 as legendaryarmory } from './responses/legendaryarmory' +import { Schema_1970_01_01 as worldbosses } from './responses/worldbosses' +import { Schema_1970_01_01 as worlds } from './responses/worlds' +import { Schema_1970_01_01 as quests } from './responses/quests' +import { Schema_1970_01_01 as stories } from './responses/stories' +import { Schema_1970_01_01 as account } from './responses/account' +import { Schema_1970_01_01 as specializations } from './responses/specializations' +import { Schema_1970_01_01 as materials } from './responses/materials' +import { Schema_1970_01_01 as guilds } from './responses/guilds' +import { Schema_1970_01_01 as characters } from './responses/characters' export interface Schema extends BaseSchema { // Account - Account: account.Schema_1970_01_01.Account + Account: account.Account // Achievements - Daily: achievements.Schema_1970_01_01.Daily - Dailies: achievements.Schema_1970_01_01.Dailies - Category: achievements.Schema_1970_01_01.Category - Achievement: achievements.Schema_1970_01_01.Achievement - Group: achievements.Schema_1970_01_01.Group + Daily: achievements.Daily + Dailies: achievements.Dailies + Category: achievements.Category + Achievement: achievements.Achievement + Group: achievements.Group // Build - Build: build.Schema_1970_01_01.Build + Build: build.Build // Character - Equipment: characters.Schema_1970_01_01.Equipment + Core: characters.Core + Equipment: characters.Equipment + Crafting: characters.Crafting + BuildTabs: characters.BuildTabs + EquipmentTabs: characters.EquipmentTabs + Inventory: characters.Inventory + Recipe: characters.Recipe + Skills: characters.Skills + // FIXME: duplicate? + CharacterSpecializations: characters.Specializations + Training: characters.Training // Home - Cats: cats.Schema_1970_01_01.Cat - Nodes: nodes.Schema_1970_01_01.Nodes + Cats: cats.Cat + Nodes: nodes.Nodes // Backstory - Answers: backstory.Schema_1970_01_01.Answer - Questions: backstory.Schema_1970_01_01.Question + Answers: backstory.Answer + Questions: backstory.Question // Currencies - Currencies: currencies.Schema_1970_01_01.Currency + Currencies: currencies.Currency // Colors - Colors: colors.Schema_1970_01_01.Color + Colors: colors.Color // Commerce - Delivery: commerce.Schema_1970_01_01.Delivery - Exchange: commerce.Schema_1970_01_01.Exchange - Listings: commerce.Schema_1970_01_01.Listing - Prices: commerce.Schema_1970_01_01.Price - Transactions: commerce.Schema_1970_01_01.Transactions + Delivery: commerce.Delivery + Exchange: commerce.Exchange + Listings: commerce.Listing + Prices: commerce.Price + Transactions: commerce.Transactions // Dailycrafting - Dailycrafting: dailycrafting.Schema_1970_01_01.DailyCrafting + Dailycrafting: dailycrafting.DailyCrafting // Dungeon - Dungeons: dungeons.Schema_1970_01_01.Dungeon + Dungeons: dungeons.Dungeon // Emblem - Emblem: emblems.Schema_1970_01_01.Emblem + Emblem: emblems.Emblem // Files - Files: files.Schema_1970_01_01.File + Files: files.File // Finisher - Finishers: finishers.Schema_1970_01_01.Finisher + Finishers: finishers.Finisher // Gliders - Gliders: gliders.Schema_1970_01_01.Glider + Gliders: gliders.Glider // Guilds - Guilds: guilds.Schema_1970_01_01.Guild - Logs: guilds.Schema_1970_01_01.Log - Members: guilds.Schema_1970_01_01.Member - Ranks: guilds.Schema_1970_01_01.Rank - Stash: guilds.Schema_1970_01_01.Stash - Storage: guilds.Schema_1970_01_01.Storage - Team: guilds.Schema_1970_01_01.Team - Treasury: guilds.Schema_1970_01_01.Treasury - Upgrades: guilds.Schema_1970_01_01.Upgrade - Permissions: guilds.Schema_1970_01_01.Permission - Search: guilds.Schema_1970_01_01.Search + Guilds: guilds.Guild + Logs: guilds.Log + Members: guilds.Member + Ranks: guilds.Rank + Stash: guilds.Stash + Storage: guilds.Storage + Team: guilds.Team + Treasury: guilds.Treasury + Upgrades: guilds.Upgrade + Permissions: guilds.Permission + Search: guilds.Search // Continents - Continents: continents.Schema_1970_01_01.Continent - Floor: continents.Schema_1970_01_01.Floor + Continents: continents.Continent + Floor: continents.Floor // Quests - Quests: quests.Schema_1970_01_01.Quest + Quests: quests.Quest // Legendary Armory - LegendaryArmory: legendaryarmory.Schema_1970_01_01.Legendaryarmory + LegendaryArmory: legendaryarmory.Legendaryarmory // Legends - Legends: legends.Schema_1970_01_01.Legend + Legends: legends.Legend // Mailcarriers - Mailcarriers: mailcarriers.Schema_1970_01_01.Mailcarrier + Mailcarriers: mailcarriers.Mailcarrier // Mapchests - Mapchests: mapchests.Schema_1970_01_01.Mapchest + Mapchests: mapchests.Mapchest // Masteries - Masteries: masteries.Schema_1970_01_01.Mastery + Masteries: masteries.Mastery // Materials - Materials: materials.Schema_1970_01_01.Material + Materials: materials.Material // Mounts - MountType: mounts.Schema_1970_01_01.Type - MountSkin: mounts.Schema_1970_01_01.Skin + MountType: mounts.Type + MountSkin: mounts.Skin // Minis - Minis: minis.Schema_1970_01_01.Mini + Minis: minis.Mini // Novelties - Novelties: novelties.Schema_1970_01_01.Novelty + Novelties: novelties.Novelty // Outfits - Outfits: outfits.Schema_1970_01_01.Outfit + Outfits: outfits.Outfit // Pets - Pets: pets.Schema_1970_01_01.Pet + Pets: pets.Pet // Professions - Professions: professions.Schema_1970_01_01.Profession + Professions: professions.Profession // Quaggans - Quaggans: quaggans.Schema_1970_01_01.Quaggan + Quaggans: quaggans.Quaggan // Races - Races: races.Schema_1970_01_01.Race + Races: races.Race // Raid - Raid: raids.Schema_1970_01_01.Raid + Raid: raids.Raid // Specializations - Specializations: specializations.Schema_1970_01_01.Specialization + Specializations: specializations.Specialization // Stories - Stories: stories.Schema_1970_01_01.Story + Stories: stories.Story // Titles - Titles: titles.Schema_1970_01_01.Title + Titles: titles.Title // Tokeninfo - Tokeninfo: tokeninfo.Schema_1970_01_01.TokenInfo + Tokeninfo: tokeninfo.TokenInfo // Trait - Traits: traits.Schema_1970_01_01.Trait + Traits: traits.Trait // Skins - Skins: skins.Schema_1970_01_01.Skin + Skins: skins.Skin // Worlds - Worlds: worlds.Schema_1970_01_01.World + Worlds: worlds.World // Worldbosses - Worldbosses: worldbosses.Schema_1970_01_01.Worldboss + Worldbosses: worldbosses.Worldboss } From 5cdb556e883c4c701d10ab80a647910776fa458f Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 8 Jul 2023 15:34:55 +0200 Subject: [PATCH 67/72] Add endpoint response for skills --- src/endpoints/schemas/responses/skills.ts | 226 +++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 5 +- 2 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 src/endpoints/schemas/responses/skills.ts diff --git a/src/endpoints/schemas/responses/skills.ts b/src/endpoints/schemas/responses/skills.ts new file mode 100644 index 0000000..51099b6 --- /dev/null +++ b/src/endpoints/schemas/responses/skills.ts @@ -0,0 +1,226 @@ +import { Profession, URL } from '../../../types' + +/** + * - Bundle – Used for Engineer kits or weapons picked up in-world. + * - Elite – Elite skill. + * - Heal – Heal skill. + * - Monster – Used for some NPC skills. + * - Pet – Used for Ranger pet skills. + * - Profession – Profession-specific skill, such as Elementalist attunements or Engineer toolbelt skills. + * - Toolbelt – Used for some Engineer toolbelt skills. + * - Transform – Placeholder skill used to indicate a locked slot. + * - Utility – Utility skill. + * - Weapon – Weapon skill or downed skill. + */ +type SkillType = 'Bundle' | 'Elite' | 'Heal' | 'Monster' | 'Pet' | 'Profession' | 'Toolbelt' | 'Utility' | 'Weapon' + +/** + * - Downed_[1-4] – Downed skills 1-4. + * - Pet - Used for Ranger pet skills. + * - Profession_[1-5] – Profession skills 1-5. + * - Utility – Utility skill. + * - Weapon_[1-5] – Weapon skills 1-5. + */ +type SkillSlot = 'Pet' | 'Utility' + | 'Downed_1' | 'Downed_2' | 'Downed_3' | 'Downed_4' + | 'Profession_1' | 'Profession_2' | 'Profession_3' | 'Profession_4' | 'Profession_5' + | 'Weapon_1' | 'Weapon_2' | 'Weapon_3' | 'Weapon_4' | 'Weapon_5' + +type SkillCategory = 'DualWield' | 'StealthAttack' | 'Signet' | 'Cantrip' + +type Attunment = 'Fire' | 'Water' | 'Air' | 'Earth' + +type SkillFlags = 'GroundTargeted' | 'NoUnderwater' + +type FactType = 'AttributeAdjust' | 'Buff' | 'ComboField' | 'ComboFinisher' | 'Damage' | 'Distance' | 'Duration' | 'Heal' | 'HealingAdjust' | 'NoData' | 'Number' | 'Percent' | 'PrefixedBuff' | 'Radius' | 'Range' | 'Recharge' | 'StunBreak' | 'Time' | 'Unblockable' + +type ComboFieldType = 'Air' | 'Dark' | 'Fire' | 'Ice' | 'Light' | 'Lightning' | 'Poison' | 'Smoke' | 'Ethereal' | 'Water' + +type ComboFinisherType = 'Blast' | 'Leap' | 'Projectile' | 'Whirl' + +interface AttributeAdjustFact extends BaseFact<'AttributeAdjust'> { + /** The amount target gets adjusted, based on a level 80 character at base stats. */ + value: number + /** The attribute this fact adjusts. Note that a value of Healing indicates the fact is a heal, and Ferocity is encoded at CritDamage. */ + target: string +} + +interface BuffFact extends BaseFact<'Buff'> { + /** The duration of the effect in seconds. Note that some facts of this type are just used to display the buff icon with text; in this case, duration is usually 0, or omitted entirely. */ + duration?: number + /** The boon, condition, or effect referred to by the fact. */ + status: string // FIXME: type + /** The description of the status effect. */ + description?: string + /** The number of stacks applied. */ + apply_count?: number +} + +interface ComboFieldFact extends BaseFact<'ComboField'> { + /** The type of field. */ + field_type: ComboFieldType +} + +interface ComboFinisherFact extends BaseFact<'ComboFinisher'> { + /** The percent chance that the finisher will trigger. */ + percent: number + /** The type of finisher. */ + finisher_type: ComboFinisherType +} + +interface DamageFact extends BaseFact<'Damage'> { + /** The amount of times the damage hits. */ + hit_count: number + /** Indicates the damage multiplier value of that skill. */ + dmg_multiplier: number +} + +interface DistanceFact extends BaseFact<'Distance'> { + /** The distance value. */ + distance: number +} + +interface DurationFact extends BaseFact<'Duration'> { + /** The duration in seconds. */ + duration: number +} + +interface HealFact extends BaseFact<'Heal'> { + /** The number of times the heal is applied. */ + hit_count: number +} + +// FIXME: honestly, this feels very much like a copy-paste error in the wiki... +interface HealingAdjustFact extends BaseFact<'HealingAdjust'> { + hit_count: number +} + +interface NoDataFact extends BaseFact<'NoData'> { +} + +interface NumberFact extends BaseFact<'Number'> { + /** The number value as referenced by `text`. */ + value: number +} + +interface PerecentFact extends BaseFact<'Percent'> { + /** The percentage value as referenced by `text`. */ + percent: number +} + +interface PrefixedBuffFact extends BaseFact<'PrefixedBuff'> { + /** The duration of the effect in seconds. Note that some facts of this type are just used to display the buff icon with text; in this case, duration is usually 0, or omitted entirely. */ + duration?: number + /** The boon, condition, or effect referred to by the fact. */ + status: string // FIXME: type + /** The description of the status effect. */ + description?: string + /** The number of stacks applied. */ + apply_count?: number + prefix: { + text: string, + icon: URL, + status: string, + description: string + } +} + +interface RadiusFact extends BaseFact<'Radius'> { + /** The radius value. */ + distance: number +} + +interface RangeFact extends BaseFact<'Range'> { + /** The range of the trait/skill. */ + value: number +} + +interface RechargeFact extends BaseFact<'Recharge'> { + /** The recharge time in seconds. */ + value: number +} + +interface StunBreakFact extends BaseFact<'StunBreak'> { + value: true +} + +interface TimeFact extends BaseFact<'Time'> { + /** The time value in seconds. */ + duration: number +} + +interface UnblockableFact extends BaseFact<'Unblockable'> { + value: true +} + +type Fact = AttributeAdjustFact | BuffFact | ComboFieldFact | ComboFinisherFact | DamageFact | DistanceFact | DurationFact | HealFact | HealingAdjustFact | NoDataFact | PerecentFact | PrefixedBuffFact | RadiusFact | RangeFact | RechargeFact | StunBreakFact | TimeFact | UnblockableFact + +// we'll have to make an exception from the "always interfaces over types"-rule here to accomodate TraitedFacts that are actually just mixins of some additional properties +type TraitedFact = Fact & { + /** Specifies which trait has to be selected in order for this fact to take effect. */ + requires_trait: number + /** This specifies the array index of the facts object it will override, if the trait specified in requires_trait is selected. If this field is omitted, then the fact contained within this object is to be appended to the existing facts array. */ + overrides?: number +} + +interface BaseFact { + /** An arbitrary localized string describing the fact. */ + text: string + /** A URL to the icon shown with the fact. Not included with all facts. */ + icon?: URL + /** Defines what additional fields the object will contain, and what type of fact it is. Can be one of the following: */ + type: T +} + + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/skills} */ + export interface Skill { + /** The skill id. */ + id: number + /** The skill name. */ + name: string + /** The skill description. */ + description?: string + /** A URL to an icon of the skill. */ + icon: string + /** The chat link. */ + chat_link: string + /** The skill type (see below). Possible values: */ + type?: SkillType + /** Indicates what weapon the skill is on. Can also be None if not applicable. */ + weapon_type?: string + /** An array of strings indicating which profession(s) can use this skill. */ + professions: Array + /** A string indicating where this skill fits into. Possible values: */ + slot?: SkillSlot + /** An array of skill fact objects describing the skill's effect. (See below.) */ + facts?: Array + /** An array of skill fact objects that may apply to the skill, dependent on the player's trait choices. */ + traited_facts?: Array + /** An array of categories the skill falls under. Mostly used for organizational purposes, with some exceptions: */ + categories?: Array + /** Used for Elementalist weapon skills, indicates what attunement this skill falls under. One of: Fire, Water, Air, Earth. */ + attunement?: Attunment + /** Used for Revenant, Warrior, and Druid skills to indicate their energy cost. */ + cost?: number + /** Indicates what off-hand must be equipped for this dual-wield skill to appear. */ + dual_wield?: string + /** Used for skills that "flip over" into a new skill in the same slot to indicate what skill they flip to, such as Engineer toolkits or Herald facets. */ + flip_skill?: number + /** Indicates the Initiative cost for thief skills. */ + initiative?: number + /** Indicates the next skill in the chain, if applicable. */ + next_chain?: number + /** Indicates the previous skill in the chain, if applicable. */ + prev_chain?: number + /** Used to indicate that the skill will transform the player, replacing their skills with the skills listed in the array. */ + transform_skills?: Array + /** Used to indicate that the skill will replace the player's skills with the skills listed in the array. */ + bundle_skills?: Array + /** Used for Engineer utility skills to indicate their associated toolbelt skill. */ + toolbelt_skill?: number + /** Used to indicate usage limitations, more than one value can be set. One of: GroundTargeted, NoUnderwater. */ + flags?: Array + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 49a88c7..e857e45 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -42,6 +42,7 @@ import { Schema_1970_01_01 as specializations } from './responses/specialization import { Schema_1970_01_01 as materials } from './responses/materials' import { Schema_1970_01_01 as guilds } from './responses/guilds' import { Schema_1970_01_01 as characters } from './responses/characters' +import { Schema_1970_01_01 as skills } from './responses/skills' export interface Schema extends BaseSchema { // Account @@ -62,7 +63,8 @@ export interface Schema extends BaseSchema { EquipmentTabs: characters.EquipmentTabs Inventory: characters.Inventory Recipe: characters.Recipe - Skills: characters.Skills + // FIXME: really need to nest! Collision with Skills + cSkills: characters.Skills // FIXME: duplicate? CharacterSpecializations: characters.Specializations Training: characters.Training @@ -152,6 +154,7 @@ export interface Schema extends BaseSchema { Tokeninfo: tokeninfo.TokenInfo // Trait Traits: traits.Trait + Skills: skills.Skill // Skins Skins: skins.Skin // Worlds From 3fe92913625dd3cb35ac0e242a5ba17cf3ff481f Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 9 Jul 2023 11:47:08 +0200 Subject: [PATCH 68/72] Add endpoint responses for event details --- src/endpoints/schemas/responses/events.ts | 49 ++++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 ++ 2 files changed, 52 insertions(+) create mode 100644 src/endpoints/schemas/responses/events.ts diff --git a/src/endpoints/schemas/responses/events.ts b/src/endpoints/schemas/responses/events.ts new file mode 100644 index 0000000..4a25f59 --- /dev/null +++ b/src/endpoints/schemas/responses/events.ts @@ -0,0 +1,49 @@ +type EventFlag = 'group_event' | 'map_wide' | 'meta_event' | 'dungeon_event' +type LocationType = 'sphere' | 'cylinder' | 'poly' +type Coordinate3D = [number, number, number] // FIXME: reuse? +type Coordinate2D = [number, number] + +interface BaseLocation { + type: T + center: Coordinate3D +} + +interface SphereLocation extends BaseLocation<'sphere'> { + radius: number + rotation: number +} + +interface CylinderLocation extends BaseLocation<'cylinder'> { + height: number + radius: number + rotation: number +} + +interface PolyLocation extends BaseLocation<'poly'> { + z_range: Coordinate2D + points: Array +} + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:1/event_details} */ + export interface EventDetails { + /** The name of the event. */ + name: string + /** The event level. */ + level: number + /** The map where the event takes place. */ + map_id: number + /** A list of additional flags. Possible flags are: */ + flags: Array + /** The location of the event. */ + location: SphereLocation | CylinderLocation | PolyLocation + /** The type of the event location, can be sphere, cylinder or poly. */ + type: string + /** The icon for the event. */ + icon?: object + /** The file id to be used with the render service. */ + file_id: number + /** The file signature to be used with the render service. */ + signature: string + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index e857e45..5360ba6 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -43,6 +43,7 @@ import { Schema_1970_01_01 as materials } from './responses/materials' import { Schema_1970_01_01 as guilds } from './responses/guilds' import { Schema_1970_01_01 as characters } from './responses/characters' import { Schema_1970_01_01 as skills } from './responses/skills' +import { Schema_1970_01_01 as events } from './responses/events' export interface Schema extends BaseSchema { // Account @@ -90,6 +91,8 @@ export interface Schema extends BaseSchema { Dungeons: dungeons.Dungeon // Emblem Emblem: emblems.Emblem + // Events + Events: events.EventDetails // Files Files: files.File // Finisher From 7a14f612fa2c4244e8398fab7877649123a4c1ce Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sat, 22 Jul 2023 16:23:31 +0200 Subject: [PATCH 69/72] Add respnses for items --- src/endpoints/schemas/responses/items.ts | 340 +++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 14 + src/types.ts | 11 +- 3 files changed, 362 insertions(+), 3 deletions(-) create mode 100644 src/endpoints/schemas/responses/items.ts diff --git a/src/endpoints/schemas/responses/items.ts b/src/endpoints/schemas/responses/items.ts new file mode 100644 index 0000000..fc303c8 --- /dev/null +++ b/src/endpoints/schemas/responses/items.ts @@ -0,0 +1,340 @@ +import { ArmorSlot, Attribute, DamageType, Profession, Weapon as WeaponType, WeightClass, Trinket as TrinketType } from "../../../types" +import { Race } from "../../../types" +import { Rarity } from "../../../types" + +/** + * Armor - Armor + * Back - Back item + * Bag - Bags + * Consumable - Consumables + * Container - Containers + * CraftingMaterial - Crafting materials + * Gathering - Gathering tools, baits and lures + * Gizmo - Gizmos + * JadeTechModule - Sensory Array and Service Chip modules + * MiniPet - Miniatures + * PowerCore - Power Cores + * Tool - Salvage kits + * Trait - Trait guides + * Trinket - Trinkets + * Trophy - Trophies + * UpgradeComponent - Upgrade components + * Weapon - Weapons + */ +type ItemType = "Armor" | "Back" | "Bag" | "Consumable" | "Container" | "CraftingMaterial" | "Gathering" | "Gizmo" | "JadeTechModule" | "MiniPet" | "PowerCore" | "Tool" | "Trait" | "Trinket" | "Trophy" | "UpgradeComponent" | "Weapon" + +/** + * AccountBindOnUse - Account bound on use + * AccountBound - Account bound on acquire + * Attuned - If the item is attuned + * BulkConsume - If the item can be bulk consumed + * DeleteWarning - If the item will prompt the player with a warning when deleting + * HideSuffix - Hide the suffix of the upgrade component + * Infused - If the item is infused + * NoMysticForge - Not usable in the Mystic Forge + * NoSalvage - Not salvageable + * NoSell - Not sellable + * NotUpgradeable - Not upgradeable + * NoUnderwater - Not available underwater + * SoulbindOnAcquire - Soulbound on acquire + * SoulBindOnUse - Soulbound on use + * Tonic - If the item is a tonic + * Unique - Unique + */ +type ItemFlag = "AccountBindOnUse" | "AccountBound" | "Attuned" | "BulkConsume" | "DeleteWarning" | "HideSuffix" | "Infused" | "NoMysticForge" | "NoSalvage" | "NoSell" | "NotUpgradeable" | "NoUnderwater" | "SoulbindOnAcquire" | "SoulBindOnUse" | "Tonic" | "Unique" + + +/** + * Activity - Usable in activities + * Dungeon - Usable in dungeons + * Pve - Usable in general PvE + * Pvp - Usable in PvP + * PvpLobby - Usable in the Heart of the Mists + * Wvw - Usable in World vs. World + */ +type GameType = "Activity" | "Dungeon" | "Pve" | "Pvp" | "PvpLobby" | "Wvw" + + +/** + * AppearanceChange - For Total Makeover Kits, Self-Style Hair Kits, and Name Change Contracts + * Booze - Alcohol consumables + * ContractNpc - For Trading Post Express, Merchant Express, Golem Banker, Banker Golem (2 weeks) + * Currency - Some currencies + * Food - Food consumables + * Generic - Various consumables + * Halloween - Some boosters + * Immediate - Consumables granting immediate effect (most boosters, Pacified Magical Storm). Also used for currency items that are consumed immediately upon receipt. + * MountRandomUnlock - For Mount licenses + * RandomUnlock - For Guaranteed (Armor, Wardrobe, Weapon; Blue-Green Dye, Purple-Gray Dye, Red-Brown Dye, Yellow-Orange Dye) Unlocks + * Transmutation - Skin consumables + * Unlock - Unlock consumables + * UpgradeRemoval - For Upgrade Extractor + * Utility - Utility items (Potions etc.) + * TeleportToFriend - Used for Teleport to Friend + */ +type ConsumableType = "AppearanceChange" | "Booze" | "ContractNpc" | "Currency" | "Food" | "Generic" | "Halloween" | "Immediate" | "MountRandomUnlock" | "RandomUnlock" | "Transmutation" | "Unlock" | "UpgradeRemoval" | "Utility" | "TeleportToFriend" + + +/** + * BagSlot - For Bag Slot Expansion + * BankTab - For Bank Tab Expansion + * Champion - For Mist Champions + * CollectibleCapacity - For Storage Expander + * Content - Finishers and Collection unlocks, and Commander's Compendium + * CraftingRecipe - Crafting recipes + * Dye - Dyes + * GliderSkin - For Gliders + * Minipet - For Miniatures + * Ms - For Mount Skins + * Outfit - For Outfits + * SharedSlot - For Shared Inventory Slots + */ +type UnlockType = "BagSlot" | "BankTab" | "Champion" | "CollectibleCapacity" | "Content" | "CraftingRecipe" | "Dye" | "GliderSkin" | "Minipet" | "Ms" | "Outfit" | "SharedSlot" + + +/** + * GiftBox - For some presents and most dye kits + * Immediate - For containers without a UI (e.g. Pile of Silky Sand, Black Lion Arsenal—Axe, Divine Passage, Iboga Petals) + * OpenUI - For containers that have their own UI when opening (Black Lion Chest) + */ +type ContainerType = "GiftBox" | "Immediate" | "OpenUI" + + +/** + * Foraging - For harvesting sickles + * Logging - For logging axes + * Mining - For mining picks + * Bait - For baits + * Lure - For lures + */ +type GatheringType = "Foraging" | "Logging" | "Mining" | "Bait" | "Lure" + + +/** + * ContainerKey - For Black Lion Chest Keys. + * RentableContractNpc - For time-limited NPC services (e.g. Golem Banker, Personal Merchant Express) + * UnlimitedConsumable - For Permanent Self-Style Hair Kit + */ +type GizmoType = "ContainerKey" | "RentableContractNpc" | "UnlimitedConsumable" + + +/** + * Default - Infusions and Jewels (and historical PvP runes/sigils) + * Gem - Universal upgrades (Gemstones, Doubloons, and Marks/Crests/etc.) + * Rune - Rune + * Sigil - Sigil + */ +type UpgradeComponentType = "Default" | "Gem" | "Rune" | "Sigil" + +interface InfixUpgrade { + /** The itemstat id that can be resolved against /v2/itemstats. The usual whitelist restrictions apply and not all itemstats may be visible */ + id: number + attributes: { + attribute: Attribute + modifier: number + }[], + /** Object containing an additional effect. This is used for Boon Duration, Condition Duration, or additional attribute bonuses for ascended trinkets or back items. */ + buff?: { + /** The skill id of the effect. */ + skill_id: number + /** The effect's description. */ + description?: string + } +} + +/** + * Enrichment - Item has an enrichment slot. + * Infusion - Item has an infusion slot. + */ +type InfusionType = 'Enrichment' | 'Infusion' + +interface InfusionSlot { + /** Infusion slot type of infusion upgrades. The array contains a maximum of one value. */ + flags: InfusionType[] + /** The infusion upgrade already in the armor piece. Only used for +5 Agony Infusions (id 49428) */ + item_id?: number +} + +/** {@link https://wiki.guildwars2.com/API:2/items} */ +export interface Item { + /** The item id. */ + id: number + /** The chat link. */ + chat_link: string + /** The item name. */ + name: string + /** The full icon URL. */ + icon?: string + /** The item description. */ + description?: string + /** The item type. */ + type: T + /** The item rarity. */ + rarity: Rarity + /** The required level. */ + level: number + /** The value in coins when selling to a vendor. (Can be non-zero even when the item has the NoSell flag.) */ + vendor_value: number + /** The default skin id. */ + default_skin?: number + /** Flags applying to the item. */ + flags: ItemFlag[] + /** The game types in which the item is usable. At least one game type is specified. */ + game_types: GameType[] + /** Restrictions applied to the item. */ + restrictions: (Race | Profession)[] + /** Lists what items this item can be upgraded into, and the method of upgrading. Each object in the array has the following attributes: */ + upgrades_into?: Array + /** Describes the method of upgrading. */ + upgrade: string + /** The item ID that results from performing the upgrade. */ + item_id: number + /** Lists what items this item can be upgraded from, and the method of upgrading. See upgrades_into for format. */ + upgrades_from?: Array + /** Additional item details if applicable, depending on the item type (see below). */ + details?: object +} + + +export namespace Schema_1970_01_01 { + + export interface Armor extends Item { + /** The weight class of the armor piece. */ + weight_class: WeightClass + /** The defense value of the armor piece. */ + defense: number + /** Infusion slots of the armor piece (see below). */ + infusion_slots: InfusionSlot[] + /** The (x) value to be combined with the (m, gradient) multiplier and (c, offset) value to calculate the value of an attribute using API:2/itemstats. */ + attribute_adjustment: number + /** The infix upgrade object (see below). */ + infix_upgrade?: InfixUpgrade + /** The suffix item id. This is usually a rune. */ + suffix_item_id?: number + /** The secondary suffix item id. Equals to an empty string if there is no secondary suffix item. */ + secondary_suffix_item_id: string + /** A list of selectable stat IDs which are visible in API:2/itemstats */ + stat_choices?: Array + } + + export interface BackItem extends Item<'Back'> { + /** Infusion slots of the back item (see below). */ + infusion_slots: InfusionSlot[] + /** The (x) value to be combined with the (m, gradient) multiplier and (c, offset) value to calculate the value of an attribute using API:2/itemstats. */ + attribute_adjustment: number + /** The infix upgrade object (see below). */ + infix_upgrade?: InfixUpgrade + /** The suffix item id. This is usually a jewel. */ + suffix_item_id?: number + /** The secondary suffix item id. Equals to an empty string if there is no secondary suffix item. */ + secondary_suffix_item_id: string + /** A list of selectable stat IDs which are visible in API:2/itemstats */ + stat_choices?: Array + } + + export interface Bag extends Item<'Bag'> { + /** The number of bag slots. */ + size: number + /** Whether the bag is invisible/safe, and contained items won't show up at merchants etc. */ + no_sell_or_sort: boolean + } + + export interface Consumable extends Omit, 'name'> { + /** Effect description for consumables applying an effect. */ + description?: string + /** Effect duration in milliseconds. */ + duration_ms?: number + /** Unlock type for unlock consumables. */ + unlock_type?: UnlockType + /** The dye id for dye unlocks. */ + color_id?: number + /** The recipe id for recipe unlocks. */ + recipe_id?: number + /** Additional recipe ids for recipe unlocks. */ + extra_recipe_ids?: Array + /** The guild upgrade id for the item; resolvable against API:2/guild/upgrades. */ + guild_upgrade_id?: number + /** The number of stacks of the effect applied by this item. */ + apply_count?: number + /** The effect type name of the consumable. */ + name?: string + /** The icon of the effect. */ + icon?: string + /** A list of skin ids which this item unlocks; resolvable against API:2/skins. */ + skins?: Array + } + + export interface Container extends Item {} + + export interface Gathering extends Item {} + + export interface Gizmo extends Item { + /** The id for the Guild Decoration which will be deposited into the Guild storage uppon consumption of the Item; resolvable against API:2/guild/upgrades. */ + guild_upgrade_id? + } + + export interface Miniature extends Item<'MiniPet'> { + /** The miniature it unlocks and can be resolved against /v2/minis */ + minipet_id: number + } + + export interface Salvagekits extends Item<'Salvage'> { + /** Number of charges. */ + charges: number + } + + export interface Trinket extends Item { + /** Infusion slots of the trinket (see below). */ + infusion_slots: InfusionSlot[] + /** The (x) value to be combined with the (m, gradient) multiplier and (c, offset) value to calculate the value of an attribute using API:2/itemstats. */ + attribute_adjustment: number + /** The infix upgrade object (see below). */ + infix_upgrade?: InfixUpgrade + /** The suffix item id. This is usually a jewel or gem. */ + suffix_item_id?: number + /** The secondary suffix item id. Equals to an empty string if there is no secondary suffix item. */ + secondary_suffix_item_id: string + /** A list of selectable stat IDs which are visible in API:2/itemstats */ + stat_choices?: Array + } + + export interface UpgradeComponent extends Omit, 'flags'> { + /** The items that can be upgraded with the upgrade component. */ + flags: WeaponType | 'HeavyArmor' | 'MediumArmor' |'LightArmor' | 'Trinket' + /** Applicable infusion slot for infusion upgrades. */ + infusion_upgrade_flags: InfusionType + /** Enrichments */ + Enrichment: any + /** Infusions */ + Infusion: any + /** The suffix appended to the item name when the component is applied. */ + suffix: string + /** The infix upgrade object (see below). */ + infix_upgrade: InfixUpgrade + /** The bonuses from runes. */ + bonuses?: Array + } + + export interface Weapon extends Item { + /** The damage type. */ + damage_type: DamageType + /** Minimum weapon strength. */ + min_power: number + /** Maximum weapon strength. */ + max_power: number + /** The defense value of the weapon (for shields). */ + defense: number + /** Infusion slots of the weapon (see below). */ + infusion_slots: InfusionSlot[] + /** The (x) value to be combined with the (m, gradient) multiplier and (c, offset) value to calculate the value of an attribute using API:2/itemstats. */ + attribute_adjustment: number + /** The infix upgrade object (see below). */ + infix_upgrade?: object + /** The suffix item id. This is usually a sigil. */ + suffix_item_id?: number + /** The secondary suffix item id. Equals to an empty string if there is no secondary suffix item. */ + secondary_suffix_item_id: string + /** A list of selectable stats IDs which are visible in API:2/itemstats */ + stat_choices?: Array + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 5360ba6..8d05796 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -44,6 +44,7 @@ import { Schema_1970_01_01 as guilds } from './responses/guilds' import { Schema_1970_01_01 as characters } from './responses/characters' import { Schema_1970_01_01 as skills } from './responses/skills' import { Schema_1970_01_01 as events } from './responses/events' +import { Schema_1970_01_01 as items } from './responses/items' export interface Schema extends BaseSchema { // Account @@ -111,6 +112,19 @@ export interface Schema extends BaseSchema { Upgrades: guilds.Upgrade Permissions: guilds.Permission Search: guilds.Search + // Items + BackItems: items.BackItem + Bags: items.Bag + Consumables: items.Consumable + Containers: items.Container + Gathering: items.Gathering + Gizmos: items.Gizmo + Miniatures: items.Miniature + SalvageKits: items.SalvageKit + Trinket: items.Trinket + UpgradeComponent: items.UpgradeComponent + Weapons: items.Weapon + Armor: items.Armor // Continents Continents: continents.Continent Floor: continents.Floor diff --git a/src/types.ts b/src/types.ts index c672658..9214bab 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,6 +3,7 @@ export type ItemID = number export type URL = string export type ISO8601 = string +export type Attribute = 'Agonyresistance' | 'BoonDuration' | 'ConditionDamage' | 'ConditionDuration' | 'CritDamage' | 'Healing' | 'Power' | 'Precision' | 'Toughness' | 'Vitality' export type Language = 'en' | 'de' | 'es' | 'fr' export type Gender = 'Male' | 'Female' export type Race = 'Human' | 'Norn' | 'Charr' | 'Sylvari' | 'Asura' @@ -10,8 +11,12 @@ export type Profession = 'Guardian' | 'Revenant' | 'Warrior' | 'Engineer' | 'Ran export type Discipline = 'Armorsmith' | 'Artificer' | 'Chef' | 'Huntsman' | 'Jeweler' | 'Leatherworker' | 'Scribe' | 'Tailor' | 'Weaponsmith' export type Region = 'Tyria' | 'Maguuma' | 'Desert' | 'Tundra' export type Rarity = 'Junk' | 'Basic' | 'Fine' | 'Masterwork' | 'Rare' | 'Exotic' | 'Ascended' | 'Legendary' -export type Weapon = 'Axe' | 'Dagger' | 'Mace' | 'Pistol' | 'Sword' | 'Scepter' | 'Focus' | 'Shield' | 'Torch' | 'Warhorn' | 'Greatsword' | 'Hammer' | 'Longbow' | 'Rifle' | 'Shortbow' | 'Staff' | 'Speargun' | 'Spear' | 'Trident' +export type Weapon = 'Axe' | 'Dagger' | 'Mace' | 'Pistol' | 'Sword' | 'Scepter' | 'Focus' | 'Shield' | 'Torch' | 'Warhorn' | 'Greatsword' | 'Hammer' | 'Longbow' | 'Rifle' | 'Shortbow' | 'Staff' | 'Speargun' | 'Spear' | 'Trident' | 'LargeBundle' | 'SmallBundle' | 'Toy' | 'ToyTwoHanded' export type Attunement = 'Fire' | 'Water' | 'Wind' | 'Earth' export type WeaponSlot = 'Weapon_1' -export type EquipmentSlot = 'HelmAquatic' | 'Backpack' | 'Coat' | 'Boots' | 'Gloves' | 'Helm' | 'Leggings' | 'Shoulders' | 'Accessory1' | 'Accessory2' | 'Ring1' | 'Ring2' | 'Amulet' | 'WeaponAquaticA' | 'WeaponAquaticB' | 'WeaponA1' | 'WeaponA2' | 'WeaponB1' | 'WeaponB2' | 'Sickle' | 'Axe' | 'Pick' -export type ColorMaterial = 'cloth' | 'metal' | 'leather' | 'fur' \ No newline at end of file +export type Trinket = 'Accessory' | 'Amulet' | 'Ring' +export type ArmorSlot = 'Coat' | 'Boots' | 'Gloves' | 'Helm' | 'Leggings' | 'Shoulders' | 'HelmAquatic' +export type EquipmentSlot = ArmorSlot | 'Backpack' | 'Accessory1' | 'Accessory2' | 'Ring1' | 'Ring2' | 'Amulet' | 'WeaponAquaticA' | 'WeaponAquaticB' | 'WeaponA1' | 'WeaponA2' | 'WeaponB1' | 'WeaponB2' | 'Sickle' | 'Axe' | 'Pick' +export type ColorMaterial = 'cloth' | 'metal' | 'leather' | 'fur' +export type WeightClass = 'Heavy' | 'Medium' | 'Light' | 'Clothing' +export type DamageType = 'Fire' | 'Ice' | 'Lightning' | 'Physical' | 'Choking' \ No newline at end of file From 96d0ef2611e04c82602c9661cf8146328bca60b7 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Fri, 28 Jul 2023 18:14:13 +0200 Subject: [PATCH 70/72] Add itemstats response --- src/endpoints/schemas/responses/items.ts | 2 +- src/endpoints/schemas/responses/itemstats.ts | 22 ++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 3 +++ src/types.ts | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/endpoints/schemas/responses/itemstats.ts diff --git a/src/endpoints/schemas/responses/items.ts b/src/endpoints/schemas/responses/items.ts index fc303c8..7be4566 100644 --- a/src/endpoints/schemas/responses/items.ts +++ b/src/endpoints/schemas/responses/items.ts @@ -278,7 +278,7 @@ export namespace Schema_1970_01_01 { minipet_id: number } - export interface Salvagekits extends Item<'Salvage'> { + export interface SalvageKit extends Item<'Salvage'> { /** Number of charges. */ charges: number } diff --git a/src/endpoints/schemas/responses/itemstats.ts b/src/endpoints/schemas/responses/itemstats.ts new file mode 100644 index 0000000..93e0cdf --- /dev/null +++ b/src/endpoints/schemas/responses/itemstats.ts @@ -0,0 +1,22 @@ +import { Attribute, Race as R, URL } from '../../../types' + +interface AttributeModifier { + /** The name of the attribute, may be one of the following: */ + attribute: Attribute + /** The multiplier number for that attribute. */ + multiplier: number + /** The value number for that attribute. */ + value: number +} + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/itemstats} */ + export interface Itemstats { + /** The itemstat id. */ + id: number + /** The name of the set of stats. */ + name: string + /** List of attribute bonuses. Each object may contain the following : */ + attributes: AttributeModifier[] + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 8d05796..4b4a3f9 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -45,6 +45,7 @@ import { Schema_1970_01_01 as characters } from './responses/characters' import { Schema_1970_01_01 as skills } from './responses/skills' import { Schema_1970_01_01 as events } from './responses/events' import { Schema_1970_01_01 as items } from './responses/items' +import { Schema_1970_01_01 as itemstats } from './responses/itemstats' export interface Schema extends BaseSchema { // Account @@ -125,6 +126,8 @@ export interface Schema extends BaseSchema { UpgradeComponent: items.UpgradeComponent Weapons: items.Weapon Armor: items.Armor + // Itemstats + Itemstats: itemstats.Itemstats // Continents Continents: continents.Continent Floor: continents.Floor diff --git a/src/types.ts b/src/types.ts index 9214bab..60ebbb0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,7 +3,7 @@ export type ItemID = number export type URL = string export type ISO8601 = string -export type Attribute = 'Agonyresistance' | 'BoonDuration' | 'ConditionDamage' | 'ConditionDuration' | 'CritDamage' | 'Healing' | 'Power' | 'Precision' | 'Toughness' | 'Vitality' +export type Attribute = 'AgonyResistance' | 'BoonDuration' | 'ConditionDamage' | 'ConditionDuration' | 'CritDamage' | 'Healing' | 'Power' | 'Precision' | 'Toughness' | 'Vitality' export type Language = 'en' | 'de' | 'es' | 'fr' export type Gender = 'Male' | 'Female' export type Race = 'Human' | 'Norn' | 'Charr' | 'Sylvari' | 'Asura' From fc57c41cd5b5c69b895e0dbec446a29a93537a9e Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Fri, 4 Aug 2023 16:46:16 +0200 Subject: [PATCH 71/72] Add maps endpoint --- src/endpoints/schemas/responses/maps.ts | 49 ++++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 2 + src/types.ts | 2 + 3 files changed, 53 insertions(+) create mode 100644 src/endpoints/schemas/responses/maps.ts diff --git a/src/endpoints/schemas/responses/maps.ts b/src/endpoints/schemas/responses/maps.ts new file mode 100644 index 0000000..d8eeb83 --- /dev/null +++ b/src/endpoints/schemas/responses/maps.ts @@ -0,0 +1,49 @@ +import { Coordinate, Race as R, URL } from '../../../types' + +/** + * BlueHome - The home borderlands of the blue worlds in WvW. + * Center - The map in WvW that resides in the center of the borderlands, Eternal Battlegrounds. + * EdgeOfTheMists - The Edge of the Mists map in WvW. + * GreenHome - The home borderlands of the green worlds in WvW. + * Instance - Instances. + * JumpPuzzle - At present only a WvW map that houses a jumping puzzle of the same name, Obsidian Sanctum. + * Public - Open world maps. + * Pvp - PvP as well as activity maps. + * RedHome - The home borderlands of the red worlds in WvW. + * Tutorial - The tutorial missions for newly created characters. + */ +type MapType = "BlueHome" | "Center" | "EdgeOfTheMists" | "GreenHome" | "Instance" | "JumpPuzzle" | "Public" | "Pvp" | "RedHome" | "Tutorial" + + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/maps} */ + export interface Map { + /** The map id. */ + id: number + /** The map name. */ + name: string + /** The minimal level of this map. */ + min_level: number + /** The maximum level of this map. */ + max_level: number + /** The default floor of this map. */ + default_floor: number + /** The map type. */ + type: MapType + /** A list of available floors for this map. */ + floors: Array + /** The id of the region this map belongs to. */ + region_id: number + /** The name of the region this map belongs to. */ + region_name?: string + /** The id of the continent this map belongs to. */ + continent_id: number + /** The name of the continent this map belongs to. */ + continent_name: string + /** The dimensions of the map, given as the coordinates of the lower-left (SW) and upper-right (NE) corners. */ + map_rect: [Coordinate, Coordinate] + /** The dimensions of the map within the continent coordinate system, given as the coordinates of the upper-left (NW) and lower-right (SE) corners. */ + continent_rect: [Coordinate, Coordinate] + } + +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 4b4a3f9..2d696b7 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -46,6 +46,7 @@ import { Schema_1970_01_01 as skills } from './responses/skills' import { Schema_1970_01_01 as events } from './responses/events' import { Schema_1970_01_01 as items } from './responses/items' import { Schema_1970_01_01 as itemstats } from './responses/itemstats' +import { Schema_1970_01_01 as maps } from './responses/maps' export interface Schema extends BaseSchema { // Account @@ -139,6 +140,7 @@ export interface Schema extends BaseSchema { Legends: legends.Legend // Mailcarriers Mailcarriers: mailcarriers.Mailcarrier + Map: maps.Map // Mapchests Mapchests: mapchests.Mapchest // Masteries diff --git a/src/types.ts b/src/types.ts index 60ebbb0..9414fdf 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,6 +3,8 @@ export type ItemID = number export type URL = string export type ISO8601 = string +export type Coordinate = [number, number] + export type Attribute = 'AgonyResistance' | 'BoonDuration' | 'ConditionDamage' | 'ConditionDuration' | 'CritDamage' | 'Healing' | 'Power' | 'Precision' | 'Toughness' | 'Vitality' export type Language = 'en' | 'de' | 'es' | 'fr' export type Gender = 'Male' | 'Female' From 51138530d77d4b0ab725190a77fac6e95e92047b Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Sun, 13 Aug 2023 00:03:50 +0200 Subject: [PATCH 72/72] Add response schema for wvw --- src/endpoints/schemas/responses/wvw.ts | 184 +++++++++++++++++++++ src/endpoints/schemas/schema_1970_01_01.ts | 8 + src/types.ts | 1 + 3 files changed, 193 insertions(+) create mode 100644 src/endpoints/schemas/responses/wvw.ts diff --git a/src/endpoints/schemas/responses/wvw.ts b/src/endpoints/schemas/responses/wvw.ts new file mode 100644 index 0000000..cb3db56 --- /dev/null +++ b/src/endpoints/schemas/responses/wvw.ts @@ -0,0 +1,184 @@ +import { Coordinate, Coordinate3, URL } from "../../../types" + +type Faction = 'red' | 'blue' | 'green' +type FactionData = { [key in Faction]: T } +type ObjectiveType = 'Spawn' | 'Camp' | 'Ruins' | 'Tower' | 'Keep' | 'Castle' | 'Mercenary' +type WvWMap = 'RedHome' | 'GreenHome' | 'BlueHome' | 'Center' + + +interface Rank { + /** The cost in WvW experience points to purchase the ability. */ + cost: number + /** The effect given to players for obtaining the given ability rank. */ + effect: string +} + +interface MatchObjective { + /** The objective id. */ + id: string + /** The objective type, with possible values Spawn, Camp, Ruins, Tower, Keep, Castle, and Mercenary (Dredge/Krait/Frogs). */ + type: ObjectiveType + /** The current owner of the objective. Can be any one of Red, Green, Blue or Neutral. */ + owner: Faction | 'Neutral' + /** The time at which this objective was last captured by a server. (ISO-8601 Standard) */ + last_flipped: string + /** The guild id of the guild currently claiming the objective, or null if not claimed. (Not present for unclaimable objectives.) */ + claimed_by?: string + /** The time the objective was claimed by the claimed_by guild (ISO-8601 Standard), or null if not claimed. (Not present for unclaimable objectives.) */ + claimed_at?: string + /** The amount of points per tick the given objective yields. */ + points_tick: number + /** The amount of points awarded for capturing the objective. */ + points_capture: number + /** An array of ids, resolvable against v2/guild/upgrades, showing which guild upgrades are currently slotted. */ + guild_upgrades?: number[] + /** The total amount of yak shipments delivered to the objective. Not limited to the shipments within the current tier only. */ + yaks_delivered?: number +} + +interface Bonus { + /** A shorthand name for the bonus. Currently can only be Bloodlust. */ + type: 'Bloodlust' + /** The color representing which world group owns the bloodlust. */ + owner: Faction +} + + + +interface Map { + /** The map id */ + id: number + /** The identifier for the map. Can be either RedHome, GreenHome or BlueHome for the borderlands or Center for Eternal Battlegrounds. */ + type: WvWMap + /** An object containing the score of the three servers for only the specified map, under the values red, blue, and green. */ + scores: FactionData + /** An object containing the total kills of the three servers for only the specified map, under the values red, blue, and green. */ + kills: FactionData + /** An object containing the total deaths of the three servers for only the specified map, under the values red, blue, and green. */ + deaths: FactionData + /** A list of objective objects for this map. Each object contains the following properties: */ + objectives: Array + /** A list of all bonuses being granted by this map. If no player team owns a bonus from the map, this list is empty. */ + bonuses: Array +} + + +interface MapScore { + /** Which map is being looked at, can have the values "Center", "RedHome", "BlueHome", or "GreenHome" */ + type: WvWMap + /** Object containing total scores for each team color on the selected map, under the values red, blue, and green. */ + scores: FactionData +} + + +interface Skirmish { + /** The skirmish id */ + id: number + /** Object containing total scores for each team color, under the values red, blue, and green. */ + scores: FactionData + /** Contains the map specific scores for the specific skirmish. */ + map_scores: Array +} + +interface Upgrade { + /** The name of the upgrade tier. */ + name: string + /** The given description for this upgrade. */ + description: string + /** The url/image link for the upgrade's icon. */ + icon: URL +} + +interface Tier { + /** The name of the upgrade tier. */ + name: string + /** The number of required yaks. */ + yaks_required: number + upgrades: Array +} + + +export namespace Schema_1970_01_01 { + /** {@link https://wiki.guildwars2.com/API:2/wvw/abilities} */ + export interface Ability { + /** The id of the abilities. */ + id: number + /** The given name for the WvW ability. */ + name: string + /** The given description for the WvW ability. */ + description: string + /** The uri for the ability's icon. */ + icon: URL + ranks: Array + } + + + /** {@link https://wiki.guildwars2.com/API:2/wvw/matches} */ + export interface Match { + /** The WvW match id. */ + id: string + /** The starting time of the matchup. (ISO-8601 Standard) */ + start_time: string + /** The ending time of the matchup. (ISO-8601 Standard) */ + end_time: string + /** An object containing the score of the three servers, under the values red, blue, and green. */ + scores: object + /** An object containing the IDs of the three primary matchup worlds. */ + worlds: FactionData + /** An object containing the world IDs of the three combined servers, under the values red, blue, and green. */ + all_worlds: FactionData + /** An object containing the total deaths of the three servers, under the values red, blue, and green. */ + deaths: FactionData + /** An object containing the total kills of the three servers, under the values red, blue, and green. */ + kills: FactionData + /** An object containing the victory points of the three servers, under the values red, blue, and green. */ + victory_points: FactionData + /** A list of objects containing detailed information about each of the four maps. The map detail objects contain the following properties: */ + maps: Array + skirmishes: Array + } + + /** {@link https://wiki.guildwars2.com/API:2/wvw/objectives} */ + export interface Objective { + /** The objective id. */ + id: string + /** The name of the objective. */ + name: string + /** The type of the objective. Possible values include: */ + type: string + /** The map sector the objective can be found in. (See /v2/continents.) */ + sector_id: any + /** The ID of the map that this objective can be found on. */ + map_id: number + /** The map that this objective can be found on. One of: GreenHome, BlueHome, RedHome, Center, or EdgeOfTheMists. */ + map_type: string + /** An array of three numbers representing the X, Y and Z coordinates of the objectives marker on the map. */ + coord: Coordinate3 + /** An array of two numbers representing the X and Y coordinates of the sector centroid. */ + label_coord: Coordinate + /** The icon link */ + marker: URL + /** The chat code for the observed objective. */ + chat_link: string + /** The upgrade id to be resolved against v2/wvw/upgrades. */ + upgrade_id: number + } + + + /** {@link https://wiki.guildwars2.com/API:2/wvw/ranks} */ + export interface Rank { + /** The id of the rank. */ + id: number + /** The given title for the WvW rank. */ + title: string + /** The minimum WvW level required to be at this rank. */ + min_rank: number + } + + /** {@link https://wiki.guildwars2.com/API:2/wvw/upgrades} */ + export interface Upgrade { + /** The upgrade id. */ + id: string + tiers: Array + } +} \ No newline at end of file diff --git a/src/endpoints/schemas/schema_1970_01_01.ts b/src/endpoints/schemas/schema_1970_01_01.ts index 2d696b7..cf6c5b0 100644 --- a/src/endpoints/schemas/schema_1970_01_01.ts +++ b/src/endpoints/schemas/schema_1970_01_01.ts @@ -47,6 +47,7 @@ import { Schema_1970_01_01 as events } from './responses/events' import { Schema_1970_01_01 as items } from './responses/items' import { Schema_1970_01_01 as itemstats } from './responses/itemstats' import { Schema_1970_01_01 as maps } from './responses/maps' +import { Schema_1970_01_01 as wvw } from './responses/wvw' export interface Schema extends BaseSchema { // Account @@ -183,4 +184,11 @@ export interface Schema extends BaseSchema { Worlds: worlds.World // Worldbosses Worldbosses: worldbosses.Worldboss + // WvW + Abilities: wvw.Ability + Matches: wvw.Match + Objective: wvw.Objective + // FIXME: collision! + wRanks: wvw.Rank + Upgrade: wvw.Upgrade } diff --git a/src/types.ts b/src/types.ts index 9414fdf..4a838f2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,6 +4,7 @@ export type URL = string export type ISO8601 = string export type Coordinate = [number, number] +export type Coordinate3 = [number, number, number] export type Attribute = 'AgonyResistance' | 'BoonDuration' | 'ConditionDamage' | 'ConditionDuration' | 'CritDamage' | 'Healing' | 'Power' | 'Precision' | 'Toughness' | 'Vitality' export type Language = 'en' | 'de' | 'es' | 'fr'