Skip to content

Commit 9ae32b4

Browse files
author
c0reme
committed
chore: content type separation
1 parent be685cc commit 9ae32b4

File tree

9 files changed

+635
-182
lines changed

9 files changed

+635
-182
lines changed

typings/index.d.ts

Lines changed: 32 additions & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
import {
2+
CharacterGetParams,
3+
CharacterGetResult,
4+
CharacterSearchParams,
5+
CharacterSearchResult,
6+
FreeCompanyGetParams,
7+
FreeCompanyGetResult,
8+
FreeCompanySearchParams,
9+
FreeCompanySearchResult,
10+
LinkshellGetResult,
11+
LinkshellSearchParams,
12+
LinkshellSearchResult,
13+
PvPTeamGetResult,
14+
PvPTeamSearchParams,
15+
PvPTeamSearchResult,
16+
SearchResult,
17+
} from "./utils";
18+
export * from "./utils";
19+
120
declare module "@xivapi/js" {
221
type StringAlgo =
322
| "custom"
@@ -12,117 +31,6 @@ declare module "@xivapi/js" {
1231
| "multi_match"
1332
| "query_string";
1433

15-
type Servers =
16-
| "Adamantine"
17-
| "Aegis"
18-
| "Alexander"
19-
| "Anima"
20-
| "Asura"
21-
| "Atomos"
22-
| "Bahamut"
23-
| "Balmung"
24-
| "Behemoth"
25-
| "Belias"
26-
| "Brynhildr"
27-
| "Cactuar"
28-
| "Carbuncle"
29-
| "Cerberus"
30-
| "Chocobo"
31-
| "Coeurl"
32-
| "Diabolos"
33-
| "Durandal"
34-
| "Excalibur"
35-
| "Exodus"
36-
| "Faerie"
37-
| "Famfrit"
38-
| "Fenrir"
39-
| "Garuda"
40-
| "Gilgamesh"
41-
| "Goblin"
42-
| "Gungnir"
43-
| "Hades"
44-
| "Hyperion"
45-
| "Ifrit"
46-
| "Ixion"
47-
| "Jenova"
48-
| "Kujata"
49-
| "Lamia"
50-
| "Leviathan"
51-
| "Lich"
52-
| "Louisoix"
53-
| "Malboro"
54-
| "Mandragora"
55-
| "Masamune"
56-
| "Mateus"
57-
| "Midgardsormr"
58-
| "Moogle"
59-
| "Odin"
60-
| "Omega"
61-
| "Pandaemonium"
62-
| "Phoenix"
63-
| "Ragnarok"
64-
| "Ramuh"
65-
| "Ridill"
66-
| "Sargatanas"
67-
| "Shinryu"
68-
| "Shiva"
69-
| "Siren"
70-
| "Tiamat"
71-
| "Titan"
72-
| "Tonberry"
73-
| "Typhon"
74-
| "Ultima"
75-
| "Ultros"
76-
| "Unicorn"
77-
| "Valefor"
78-
| "Yojimbo"
79-
| "Zalera"
80-
| "Zeromus"
81-
| "Zodiark"
82-
| "Spriggan"
83-
| "Twintania"
84-
| "Bismarck"
85-
| "Ravana"
86-
| "Sephirot"
87-
| "Sophia"
88-
| "Zurvan"
89-
| "Halicarnassus"
90-
| "Maduin"
91-
| "Marilith"
92-
| "Seraph"
93-
| "HongYuHai"
94-
| "ShenYiZhiDi"
95-
| "LaNuoXiYa"
96-
| "HuanYingQunDao"
97-
| "MengYaChi"
98-
| "YuZhouHeYin"
99-
| "WoXianXiRan"
100-
| "ChenXiWangZuo"
101-
| "BaiYinXiang"
102-
| "BaiJinHuanXiang"
103-
| "ShenQuanHen"
104-
| "ChaoFengTing"
105-
| "LvRenZhanQiao"
106-
| "FuXiaoZhiJian"
107-
| "Longchaoshendian"
108-
| "MengYuBaoJing"
109-
| "ZiShuiZhanQiao"
110-
| "YanXia"
111-
| "JingYuZhuangYuan"
112-
| "MoDuNa"
113-
| "HaiMaoChaWu"
114-
| "RouFengHaiWan"
115-
| "HuPoYuan"
116-
| "ShuiJingTa2"
117-
| "YinLeiHu2"
118-
| "TaiYangHaiAn2"
119-
| "YiXiuJiaDe2"
120-
| "HongChaChuan2"
121-
| "Alpha"
122-
| "Phantom"
123-
| "Raiden"
124-
| "Sagittarius";
125-
12634
interface XIVAPIOptions {
12735
private_key?: string;
12836
language?: "en" | "de" | "fr" | "ja" | "cn" | "ko";
@@ -131,37 +39,6 @@ declare module "@xivapi/js" {
13139
verbose?: boolean;
13240
}
13341

134-
interface SearchResponse {
135-
Pagination: {
136-
Page: number;
137-
PageNext: number;
138-
PagePrev: number | null;
139-
PageTotal: number;
140-
Results: number;
141-
ResultsPerPage: number;
142-
ResultsTotal: number;
143-
};
144-
Results: unknown[];
145-
}
146-
147-
interface SearchParams {
148-
/**
149-
* The name to search for, you can use `+` for spaces or let the API handle it for you.
150-
*/
151-
name?: string;
152-
153-
/**
154-
* The server to search against, this is case sensitive.
155-
* @see https://xivapi.com/servers
156-
*/
157-
server?: Servers;
158-
159-
/**
160-
* Search or move to a specific page.
161-
*/
162-
page?: number;
163-
}
164-
16542
interface DataSearchParams {
16643
/**
16744
* Search a specific series of indexes separated by commas.
@@ -227,11 +104,12 @@ declare module "@xivapi/js" {
227104
limit?: number;
228105
}
229106

230-
export default class XIVAPI<T = { [key: string]: any }> {
107+
export default class XIVAPI {
231108
public readonly options: XIVAPIOptions;
232109
public readonly endpoint: string;
233110
public readonly globalParams: { [key: string]: string | number };
234111

112+
constructor(options: string | XIVAPIOptions);
235113
constructor(options: string | XIVAPIOptions, legacyOptions?: XIVAPIOptions);
236114

237115
/**
@@ -247,7 +125,7 @@ declare module "@xivapi/js" {
247125
* await xiv.search("aiming", { indexes: ["Item", "Recipe"] }); // with params
248126
* ```
249127
*/
250-
public search(input: string, params?: DataSearchParams): Promise<SearchResponse>;
128+
public search(input: string, params?: DataSearchParams): Promise<SearchResult>;
251129

252130
/**
253131
* Obtain game content data of Final Fantasy XIV.
@@ -265,7 +143,7 @@ declare module "@xivapi/js" {
265143
* await xiv.data.get("Item", 1673);
266144
* ```
267145
*/
268-
get: (name: string, id: number) => Promise<T>;
146+
get: (name: string, id: string | number) => Promise<{ [key: string]: any }>;
269147

270148
/**
271149
* Obtain game content data of Final Fantasy XIV.
@@ -293,7 +171,7 @@ declare module "@xivapi/js" {
293171
*/
294172
ids?: number[];
295173
}
296-
) => Promise<SearchResponse>;
174+
) => Promise<SearchResult>;
297175

298176
/**
299177
* Returns information about a specific object including extended information.
@@ -316,22 +194,8 @@ declare module "@xivapi/js" {
316194
* @see https://xivapi.com/docs/Character
317195
*/
318196
public character: {
319-
search: (name: string, params?: SearchParams) => Promise<SearchResponse>;
320-
get: (
321-
id: number,
322-
params?: {
323-
/**
324-
* If set to 1, the API will return more data in the response by extending out the data IDs to useful objects.
325-
*/
326-
extended?: 1;
327-
328-
/**
329-
* By default the `Character`, `ClassJobs`, `Minion` and `Mount` data will return, you can request more data using the `data` query.
330-
* @see https://xivapi.com/docs/Character#character
331-
*/
332-
data?: ("AC" | "FR" | "FC" | "FC" | "FCM" | "MIMO" | "PVP")[];
333-
}
334-
) => Promise<T>;
197+
search: (name: string, params?: CharacterSearchParams) => Promise<CharacterSearchResult>;
198+
get: (id: string | number, params?: CharacterGetParams) => Promise<CharacterGetResult>;
335199
};
336200

337201
/**
@@ -340,22 +204,8 @@ declare module "@xivapi/js" {
340204
* @see https://xivapi.com/docs/Free-Company
341205
*/
342206
public freecompany: {
343-
search: (name: string, params?: SearchParams) => Promise<SearchResponse>;
344-
get: (
345-
id: number,
346-
params?: {
347-
/**
348-
* If set to 1, the API will return more data in the response by extending out the data IDs to useful objects.
349-
*/
350-
extended?: 1;
351-
352-
/**
353-
* By default only the `FreeCompany` data will return, you can request more data using the `data` query.
354-
* @see https://xivapi.com/docs/Free-Company#free-company
355-
*/
356-
data?: ["FCM"];
357-
}
358-
) => Promise<T>;
207+
search: (name: string, params?: FreeCompanySearchParams) => Promise<FreeCompanySearchResult>;
208+
get: (id: string | number, params?: FreeCompanyGetParams) => Promise<FreeCompanyGetResult>;
359209
};
360210

361211
/**
@@ -364,8 +214,8 @@ declare module "@xivapi/js" {
364214
* @see https://xivapi.com/docs/Linkshell
365215
*/
366216
public linkshell: {
367-
search: (name: string, params?: SearchParams) => Promise<SearchResponse>;
368-
get: (id: number) => Promise<T>;
217+
search: (name: string, params?: LinkshellSearchParams) => Promise<LinkshellSearchResult>;
218+
get: (id: string | number) => Promise<LinkshellGetResult>;
369219
};
370220

371221
/**
@@ -374,8 +224,8 @@ declare module "@xivapi/js" {
374224
* @see https://xivapi.com/docs/PvP-Team
375225
*/
376226
public pvpteam: {
377-
search: (name: string, params?: SearchParams) => Promise<SearchResponse>;
378-
get: (id: number) => Promise<T>;
227+
search: (name: string, params?: PvPTeamSearchParams) => Promise<PvPTeamSearchResult>;
228+
get: (id: string | number) => Promise<PvPTeamGetResult>;
379229
};
380230
}
381231
}

typings/utils/achievements.d.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { GamePatchData, ItemData, TitleData } from "./item";
2+
import { SearchResult } from "./search";
3+
4+
export interface AchievementsData {
5+
List: { Date: number; ID: number }[];
6+
Points: number;
7+
}
8+
9+
export interface AchievementsSearchResult extends SearchResult {
10+
Results: { ID: number; Icon: string; Name: string; Url: string }[];
11+
}
12+
13+
export interface AchievementCategoryData {
14+
AchievementsKind: {
15+
ID: number;
16+
Name: string;
17+
Name_de: string;
18+
Name_en: string;
19+
Name_fr: string;
20+
Name_ja: string;
21+
Order: number;
22+
};
23+
AchievementKindTarget: string;
24+
AchievementKindTargetID: number;
25+
HideCategory: number;
26+
ID: number;
27+
Name: string;
28+
Name_de: string;
29+
Name_en: string;
30+
Name_fr: string;
31+
Name_ja: string;
32+
Order: number;
33+
ShowComplete: number;
34+
}
35+
36+
export interface AchievementGetResult {
37+
AchievementCategory: AchievementCategoryData;
38+
AchievementCategoryTarget: string;
39+
AchievementCategoryTargetID: number;
40+
AchievementHideCondition: string | null;
41+
AchievementHideConditionTarget: string;
42+
AchievementHideConditionTargetID: number;
43+
AchievementTarget: { ID: number; Type: 1; Value: number } | null;
44+
AchievementTargetID: number | null;
45+
ClassJobRequirements: {}[];
46+
Data0: number;
47+
Data1: number;
48+
Data2: number;
49+
Data3: number;
50+
Data4: number;
51+
Data5: number;
52+
Data6: number;
53+
Data7: number;
54+
Description: string;
55+
Description_de: string;
56+
Description_en: string;
57+
Description_fr: string;
58+
Description_ja: string;
59+
GameContentLinks: [];
60+
GamePatch: GamePatchData;
61+
ID: number;
62+
Icon: string;
63+
IconHD: string;
64+
ItemID: number;
65+
Item: ItemData | null;
66+
ItemTarget: string;
67+
ItemTargetID: number;
68+
Key: number;
69+
Name: string;
70+
Name_de: string;
71+
Name_en: string;
72+
Name_fr: string;
73+
Name_ja: string;
74+
Order: number;
75+
Patch: number | null;
76+
Points: number;
77+
PostAchievements: [];
78+
PreAchievements: [];
79+
QuestRequirements: {}[];
80+
QuestRequirementsAll: boolean;
81+
Title: TitleData | null;
82+
TitleTarget: string;
83+
TitleTargetID: number;
84+
Type: number;
85+
Url: string;
86+
}

0 commit comments

Comments
 (0)