guildwars2-ts 1.1.1 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -10
- package/dist/index.d.mts +171 -31
- package/dist/index.d.ts +171 -31
- package/dist/index.js +285 -41
- package/dist/index.mjs +285 -41
- package/package.json +12 -12
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -20,10 +20,7 @@ const api: GW2Api = new GW2Api({
|
|
|
20
20
|
// Token is not required for all of the endpoints
|
|
21
21
|
token: "YOUR-TOKEN-HERE",
|
|
22
22
|
language: ApiLanguage.English,
|
|
23
|
-
|
|
24
|
-
retry: true,
|
|
25
|
-
attempts: 3,
|
|
26
|
-
},
|
|
23
|
+
rateLimitRetry: true
|
|
27
24
|
});
|
|
28
25
|
|
|
29
26
|
(async () => {
|
|
@@ -42,12 +39,6 @@ const api: GW2Api = new GW2Api({
|
|
|
42
39
|
|
|
43
40
|
If you find any kinds of errors in the program code, or wish to add/update any of the functionality provided by this project, please feel free to open a pull request. Validation error logs are extremely helpful, so please include them in the request
|
|
44
41
|
|
|
45
|
-
## Plans
|
|
46
|
-
- Data caching for repeated requests
|
|
47
|
-
- Better logging
|
|
48
|
-
- Support for different schemas, when available
|
|
49
|
-
- Endpoint structure rework (backend only)
|
|
50
|
-
|
|
51
42
|
[npm-image]: https://img.shields.io/npm/v/guildwars2-ts
|
|
52
43
|
[npm-link]: https://www.npmjs.com/package/guildwars2-ts
|
|
53
44
|
[license]: https://img.shields.io/gitlab/license/dinckelman%2Fguildwars2-ts
|
package/dist/index.d.mts
CHANGED
|
@@ -26,17 +26,8 @@ type UrlParams = Record<string, string | number | string[] | number[]>;
|
|
|
26
26
|
interface ApiParams {
|
|
27
27
|
token?: string;
|
|
28
28
|
language?: ApiLanguage;
|
|
29
|
-
|
|
29
|
+
rateLimitRetry?: boolean;
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Ratelimiting parameters
|
|
33
|
-
*/
|
|
34
|
-
type RatelimitParams = {
|
|
35
|
-
retry: true;
|
|
36
|
-
attempts: number;
|
|
37
|
-
} | {
|
|
38
|
-
retry: false;
|
|
39
|
-
};
|
|
40
31
|
|
|
41
32
|
/**
|
|
42
33
|
* Base Api object. Implements anything needed for the requests to all endpoints
|
|
@@ -58,8 +49,9 @@ declare class ApiBase {
|
|
|
58
49
|
* @param endpoint - API Endpoint
|
|
59
50
|
* @param apiParams - Query string
|
|
60
51
|
* @param responseType - Type of the response
|
|
52
|
+
* @param attempts - Previously failed retry count
|
|
61
53
|
*/
|
|
62
|
-
protected buildRequest<T extends z.ZodType>(endpoint: Endpoint, apiParams: UrlParams, responseType: T): Promise<z.infer<T>>;
|
|
54
|
+
protected buildRequest<T extends z.ZodType>(endpoint: Endpoint, apiParams: UrlParams, responseType: T, attempts?: number): Promise<z.infer<T>>;
|
|
63
55
|
/**
|
|
64
56
|
* Retries failed requests
|
|
65
57
|
*
|
|
@@ -70,7 +62,7 @@ declare class ApiBase {
|
|
|
70
62
|
* @param rateLimitAttempt - Current rate-limit retry counter
|
|
71
63
|
* @param prevError - Error that caused a retry
|
|
72
64
|
*/
|
|
73
|
-
protected retryRequest<T extends z.ZodType>(endpoint: Endpoint, prevOptions: RawAxiosRequestConfig, responseType: T, apiParams: UrlParams, rateLimitAttempt
|
|
65
|
+
protected retryRequest<T extends z.ZodType>(endpoint: Endpoint, prevOptions: RawAxiosRequestConfig, responseType: T, apiParams: UrlParams, rateLimitAttempt: number, prevError?: unknown): Promise<T>;
|
|
74
66
|
/**
|
|
75
67
|
* Builds final Api url from the endpoint and provided parameters
|
|
76
68
|
*
|
|
@@ -339,6 +331,70 @@ declare class AccountApi extends ApiBase {
|
|
|
339
331
|
id: number;
|
|
340
332
|
value: number;
|
|
341
333
|
}[]>;
|
|
334
|
+
/**
|
|
335
|
+
* Returns the current set of daily Wizard's Vault achievements for the account.
|
|
336
|
+
*/
|
|
337
|
+
getWizardsVaultDaily(): Promise<{
|
|
338
|
+
objectives: {
|
|
339
|
+
id: number;
|
|
340
|
+
title: string;
|
|
341
|
+
track: string;
|
|
342
|
+
acclaim: number;
|
|
343
|
+
progress_current: number;
|
|
344
|
+
progress_complete: number;
|
|
345
|
+
claimed: boolean;
|
|
346
|
+
}[];
|
|
347
|
+
meta_progress_current: number;
|
|
348
|
+
meta_progress_complete: number;
|
|
349
|
+
meta_reward_item_id: number;
|
|
350
|
+
meta_reward_astral: number;
|
|
351
|
+
meta_reward_claimed: boolean;
|
|
352
|
+
}>;
|
|
353
|
+
/**
|
|
354
|
+
* Returns the current set of Wizard's Vault rewards, along with details about which have already been purchased by the account, and in what quantity.
|
|
355
|
+
*/
|
|
356
|
+
getWizardsVaultListings(): Promise<{
|
|
357
|
+
id: number;
|
|
358
|
+
type: "Featured" | "Normal" | "Legacy";
|
|
359
|
+
item_id: number;
|
|
360
|
+
item_count: number;
|
|
361
|
+
cost: number;
|
|
362
|
+
purchased?: number | undefined;
|
|
363
|
+
purchase_limit?: number | undefined;
|
|
364
|
+
}[]>;
|
|
365
|
+
/**
|
|
366
|
+
* Returns the current set of special Wizard's Vault achievements for the account.
|
|
367
|
+
*/
|
|
368
|
+
getWizardsVaultSpecial(): Promise<{
|
|
369
|
+
objectives: {
|
|
370
|
+
id: number;
|
|
371
|
+
title: string;
|
|
372
|
+
track: string;
|
|
373
|
+
acclaim: number;
|
|
374
|
+
progress_current: number;
|
|
375
|
+
progress_complete: number;
|
|
376
|
+
claimed: boolean;
|
|
377
|
+
}[];
|
|
378
|
+
}>;
|
|
379
|
+
/**
|
|
380
|
+
* Returns the current set of weekly Wizard's Vault achievements for the account.
|
|
381
|
+
*/
|
|
382
|
+
getWizardsVaultWeekly(): Promise<{
|
|
383
|
+
objectives: {
|
|
384
|
+
id: number;
|
|
385
|
+
title: string;
|
|
386
|
+
track: string;
|
|
387
|
+
acclaim: number;
|
|
388
|
+
progress_current: number;
|
|
389
|
+
progress_complete: number;
|
|
390
|
+
claimed: boolean;
|
|
391
|
+
}[];
|
|
392
|
+
meta_progress_current: number;
|
|
393
|
+
meta_progress_complete: number;
|
|
394
|
+
meta_reward_item_id: number;
|
|
395
|
+
meta_reward_astral: number;
|
|
396
|
+
meta_reward_claimed: boolean;
|
|
397
|
+
}>;
|
|
342
398
|
/**
|
|
343
399
|
* Returns information about which world bosses have been killed by the account since daily-reset.
|
|
344
400
|
*/
|
|
@@ -432,16 +488,16 @@ declare const BackstoryAnswersDTO: z.ZodArray<z.ZodObject<{
|
|
|
432
488
|
races: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
433
489
|
}, "strip", z.ZodTypeAny, {
|
|
434
490
|
id: string;
|
|
435
|
-
description: string;
|
|
436
491
|
title: string;
|
|
492
|
+
description: string;
|
|
437
493
|
journal: string;
|
|
438
494
|
question: number;
|
|
439
495
|
professions?: string[] | undefined;
|
|
440
496
|
races?: string[] | undefined;
|
|
441
497
|
}, {
|
|
442
498
|
id: string;
|
|
443
|
-
description: string;
|
|
444
499
|
title: string;
|
|
500
|
+
description: string;
|
|
445
501
|
journal: string;
|
|
446
502
|
question: number;
|
|
447
503
|
professions?: string[] | undefined;
|
|
@@ -468,17 +524,17 @@ declare const BackstoryQuestionsDTO: z.ZodArray<z.ZodObject<{
|
|
|
468
524
|
professions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
469
525
|
}, "strip", z.ZodTypeAny, {
|
|
470
526
|
id: number;
|
|
527
|
+
title: string;
|
|
471
528
|
description: string;
|
|
472
529
|
order: number;
|
|
473
|
-
title: string;
|
|
474
530
|
answers: string[];
|
|
475
531
|
races?: string[] | undefined;
|
|
476
532
|
professions?: string[] | undefined;
|
|
477
533
|
}, {
|
|
478
534
|
id: number;
|
|
535
|
+
title: string;
|
|
479
536
|
description: string;
|
|
480
537
|
order: number;
|
|
481
|
-
title: string;
|
|
482
538
|
answers: string[];
|
|
483
539
|
races?: string[] | undefined;
|
|
484
540
|
professions?: string[] | undefined;
|
|
@@ -1799,8 +1855,9 @@ declare const ColorsDTO: z.ZodArray<z.ZodObject<{
|
|
|
1799
1855
|
/** ID of the dye item. */
|
|
1800
1856
|
item: z.ZodOptional<z.ZodNumber>;
|
|
1801
1857
|
/** Color categories. */
|
|
1802
|
-
categories: z.
|
|
1858
|
+
categories: z.ZodUnion<[z.ZodTuple<[z.ZodEnum<["Gray", "Brown", "Red", "Orange", "Yellow", "Green", "Blue", "Purple"]>, z.ZodEnum<["Vibrant", "Leather", "Metal"]>, z.ZodEnum<["Starter", "Common", "Uncommon", "Rare", "Exclusive"]>], null>, z.ZodArray<z.ZodUndefined, "many">]>;
|
|
1803
1859
|
}, "strip", z.ZodTypeAny, {
|
|
1860
|
+
categories: (undefined[] | ["Gray" | "Brown" | "Red" | "Orange" | "Yellow" | "Green" | "Blue" | "Purple", "Vibrant" | "Leather" | "Metal", "Starter" | "Common" | "Uncommon" | "Rare" | "Exclusive"]) & (undefined[] | ["Gray" | "Brown" | "Red" | "Orange" | "Yellow" | "Green" | "Blue" | "Purple", "Vibrant" | "Leather" | "Metal", "Starter" | "Common" | "Uncommon" | "Rare" | "Exclusive"] | undefined);
|
|
1804
1861
|
id: number;
|
|
1805
1862
|
name: string;
|
|
1806
1863
|
base_rgb: number[];
|
|
@@ -1837,8 +1894,8 @@ declare const ColorsDTO: z.ZodArray<z.ZodObject<{
|
|
|
1837
1894
|
rgb: number[];
|
|
1838
1895
|
} | undefined;
|
|
1839
1896
|
item?: number | undefined;
|
|
1840
|
-
categories?: ["Gray" | "Brown" | "Red" | "Orange" | "Yellow" | "Green" | "Blue" | "Purple", "Vibrant" | "Leather" | "Metal", "Starter" | "Common" | "Uncommon" | "Rare" | "Exclusive"] | undefined;
|
|
1841
1897
|
}, {
|
|
1898
|
+
categories: (undefined[] | ["Gray" | "Brown" | "Red" | "Orange" | "Yellow" | "Green" | "Blue" | "Purple", "Vibrant" | "Leather" | "Metal", "Starter" | "Common" | "Uncommon" | "Rare" | "Exclusive"]) & (undefined[] | ["Gray" | "Brown" | "Red" | "Orange" | "Yellow" | "Green" | "Blue" | "Purple", "Vibrant" | "Leather" | "Metal", "Starter" | "Common" | "Uncommon" | "Rare" | "Exclusive"] | undefined);
|
|
1842
1899
|
id: number;
|
|
1843
1900
|
name: string;
|
|
1844
1901
|
base_rgb: number[];
|
|
@@ -1875,7 +1932,6 @@ declare const ColorsDTO: z.ZodArray<z.ZodObject<{
|
|
|
1875
1932
|
rgb: number[];
|
|
1876
1933
|
} | undefined;
|
|
1877
1934
|
item?: number | undefined;
|
|
1878
|
-
categories?: ["Gray" | "Brown" | "Red" | "Orange" | "Yellow" | "Green" | "Blue" | "Purple", "Vibrant" | "Leather" | "Metal", "Starter" | "Common" | "Uncommon" | "Rare" | "Exclusive"] | undefined;
|
|
1879
1935
|
}>, "many">;
|
|
1880
1936
|
|
|
1881
1937
|
/**
|
|
@@ -5836,10 +5892,10 @@ declare const LegendaryArmoryDTO: z.ZodArray<z.ZodObject<{
|
|
|
5836
5892
|
max_count: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<4>, z.ZodLiteral<7>, z.ZodLiteral<8>]>;
|
|
5837
5893
|
}, "strip", z.ZodTypeAny, {
|
|
5838
5894
|
id: number;
|
|
5839
|
-
max_count:
|
|
5895
|
+
max_count: 4 | 2 | 1 | 7 | 8;
|
|
5840
5896
|
}, {
|
|
5841
5897
|
id: number;
|
|
5842
|
-
max_count:
|
|
5898
|
+
max_count: 4 | 2 | 1 | 7 | 8;
|
|
5843
5899
|
}>, "many">;
|
|
5844
5900
|
|
|
5845
5901
|
/**
|
|
@@ -6086,16 +6142,16 @@ declare const MinisDTO: z.ZodArray<z.ZodObject<{
|
|
|
6086
6142
|
}, "strip", z.ZodTypeAny, {
|
|
6087
6143
|
id: number;
|
|
6088
6144
|
name: string;
|
|
6145
|
+
item_id: number;
|
|
6089
6146
|
order: number;
|
|
6090
6147
|
icon: string;
|
|
6091
|
-
item_id: number;
|
|
6092
6148
|
unlock?: string | undefined;
|
|
6093
6149
|
}, {
|
|
6094
6150
|
id: number;
|
|
6095
6151
|
name: string;
|
|
6152
|
+
item_id: number;
|
|
6096
6153
|
order: number;
|
|
6097
6154
|
icon: string;
|
|
6098
|
-
item_id: number;
|
|
6099
6155
|
unlock?: string | undefined;
|
|
6100
6156
|
}>, "many">;
|
|
6101
6157
|
|
|
@@ -9744,6 +9800,58 @@ declare const StoriesSeasonsDTO: z.ZodArray<z.ZodObject<{
|
|
|
9744
9800
|
order: number;
|
|
9745
9801
|
}>, "many">;
|
|
9746
9802
|
|
|
9803
|
+
/**
|
|
9804
|
+
* /v2/wizardsvault/listings definition
|
|
9805
|
+
*/
|
|
9806
|
+
declare const WizardsVaultListingsDTO: z.ZodArray<z.ZodObject<{
|
|
9807
|
+
/** The listing id. */
|
|
9808
|
+
id: z.ZodNumber;
|
|
9809
|
+
/** The id of the item */
|
|
9810
|
+
item_id: z.ZodNumber;
|
|
9811
|
+
/** The quantity of the item the user receives */
|
|
9812
|
+
item_count: z.ZodNumber;
|
|
9813
|
+
/** Appears to be the position in the wizards vault UI. */
|
|
9814
|
+
type: z.ZodEnum<["Featured", "Normal", "Legacy"]>;
|
|
9815
|
+
/** The quantity of Astral Acclaim to purchase . */
|
|
9816
|
+
cost: z.ZodNumber;
|
|
9817
|
+
}, "strip", z.ZodTypeAny, {
|
|
9818
|
+
id: number;
|
|
9819
|
+
type: "Featured" | "Normal" | "Legacy";
|
|
9820
|
+
item_id: number;
|
|
9821
|
+
item_count: number;
|
|
9822
|
+
cost: number;
|
|
9823
|
+
}, {
|
|
9824
|
+
id: number;
|
|
9825
|
+
type: "Featured" | "Normal" | "Legacy";
|
|
9826
|
+
item_id: number;
|
|
9827
|
+
item_count: number;
|
|
9828
|
+
cost: number;
|
|
9829
|
+
}>, "many">;
|
|
9830
|
+
|
|
9831
|
+
/**
|
|
9832
|
+
* /v2/wizardsvault/objectives definition
|
|
9833
|
+
*/
|
|
9834
|
+
declare const WizardsVaultObjectivesDTO: z.ZodArray<z.ZodObject<{
|
|
9835
|
+
/** The ID of the objective. */
|
|
9836
|
+
id: z.ZodNumber;
|
|
9837
|
+
/** The title of the objective. */
|
|
9838
|
+
title: z.ZodString;
|
|
9839
|
+
/** The reward track containing the objective. */
|
|
9840
|
+
track: z.ZodEnum<["PvP", "WvW", "PvE"]>;
|
|
9841
|
+
/** The amount of astral acclaim awarded. */
|
|
9842
|
+
acclaim: z.ZodNumber;
|
|
9843
|
+
}, "strip", z.ZodTypeAny, {
|
|
9844
|
+
id: number;
|
|
9845
|
+
title: string;
|
|
9846
|
+
track: "PvP" | "WvW" | "PvE";
|
|
9847
|
+
acclaim: number;
|
|
9848
|
+
}, {
|
|
9849
|
+
id: number;
|
|
9850
|
+
title: string;
|
|
9851
|
+
track: "PvP" | "WvW" | "PvE";
|
|
9852
|
+
acclaim: number;
|
|
9853
|
+
}>, "many">;
|
|
9854
|
+
|
|
9747
9855
|
/**
|
|
9748
9856
|
* /v2/wvw/abilities definition
|
|
9749
9857
|
*/
|
|
@@ -11020,8 +11128,8 @@ declare class GuildApi extends ApiBase {
|
|
|
11020
11128
|
} | {
|
|
11021
11129
|
type: "stash";
|
|
11022
11130
|
count: number;
|
|
11023
|
-
coins: number;
|
|
11024
11131
|
item_id: number;
|
|
11132
|
+
coins: number;
|
|
11025
11133
|
operation: "deposit" | "withdraw" | "move";
|
|
11026
11134
|
} | {
|
|
11027
11135
|
type: "motd";
|
|
@@ -12291,6 +12399,39 @@ declare class PvPApi extends ApiBase {
|
|
|
12291
12399
|
}>;
|
|
12292
12400
|
}
|
|
12293
12401
|
|
|
12402
|
+
declare class WizardsVaultApi extends ApiBase {
|
|
12403
|
+
/**
|
|
12404
|
+
* Returns information about the current Wizard's Vault season.
|
|
12405
|
+
*/
|
|
12406
|
+
get(): Promise<{
|
|
12407
|
+
listings: number[];
|
|
12408
|
+
objectives: number[];
|
|
12409
|
+
title: string;
|
|
12410
|
+
start: string;
|
|
12411
|
+
end: string;
|
|
12412
|
+
}>;
|
|
12413
|
+
/**
|
|
12414
|
+
* Returns details about listings in the Wizard's Vault.
|
|
12415
|
+
*/
|
|
12416
|
+
getListings(): Promise<z.infer<typeof numberArrayType>>;
|
|
12417
|
+
/**
|
|
12418
|
+
* Returns details about listings in the Wizard's Vault.
|
|
12419
|
+
*
|
|
12420
|
+
* @param ids - (optional) List of listing ids, or "all".
|
|
12421
|
+
*/
|
|
12422
|
+
getListings(ids: number[] | 'all'): Promise<z.infer<typeof WizardsVaultListingsDTO>>;
|
|
12423
|
+
/**
|
|
12424
|
+
* Returns all Wizard's Vault's objectives in the game.
|
|
12425
|
+
*/
|
|
12426
|
+
getObjectives(): Promise<z.infer<typeof numberArrayType>>;
|
|
12427
|
+
/**
|
|
12428
|
+
* Returns all Wizard's Vault's objectives in the game.
|
|
12429
|
+
*
|
|
12430
|
+
* @param ids - (optional) List of objective ids, or "all".
|
|
12431
|
+
*/
|
|
12432
|
+
getObjectives(ids: number[] | 'all'): Promise<z.infer<typeof WizardsVaultObjectivesDTO>>;
|
|
12433
|
+
}
|
|
12434
|
+
|
|
12294
12435
|
/**
|
|
12295
12436
|
* /v2/wvw Api
|
|
12296
12437
|
*/
|
|
@@ -12517,6 +12658,8 @@ declare class GW2Api extends ApiBase {
|
|
|
12517
12658
|
readonly tokenInfo: TokenInfoApi;
|
|
12518
12659
|
/** /v2/traits Api */
|
|
12519
12660
|
readonly traits: TraitsApi;
|
|
12661
|
+
/** /v2/wizardsvault Api */
|
|
12662
|
+
readonly wizardsVault: WizardsVaultApi;
|
|
12520
12663
|
/** /v2/worldbosses Api */
|
|
12521
12664
|
readonly worldBosses: WorldBossesApi;
|
|
12522
12665
|
/** /v2/worlds Api */
|
|
@@ -12529,13 +12672,10 @@ declare class GW2Api extends ApiBase {
|
|
|
12529
12672
|
* TSlog log level
|
|
12530
12673
|
*/
|
|
12531
12674
|
declare enum LogLevel {
|
|
12532
|
-
silly = 0,
|
|
12533
|
-
trace = 1,
|
|
12534
|
-
debug = 2,
|
|
12535
|
-
info = 3,
|
|
12536
|
-
warn = 4,
|
|
12537
12675
|
error = 5,
|
|
12538
|
-
|
|
12676
|
+
warn = 4,
|
|
12677
|
+
info = 3,
|
|
12678
|
+
debug = 2
|
|
12539
12679
|
}
|
|
12540
12680
|
/**
|
|
12541
12681
|
* Set logger level
|
|
@@ -12550,4 +12690,4 @@ declare const setLogLevel: (minLevel: LogLevel) => void;
|
|
|
12550
12690
|
*/
|
|
12551
12691
|
declare const setPathLogging: (displayFilePath: boolean) => void;
|
|
12552
12692
|
|
|
12553
|
-
export { ApiLanguage, ApiParams, GW2Api, LogLevel,
|
|
12693
|
+
export { ApiLanguage, type ApiParams, GW2Api, LogLevel, setLogLevel, setPathLogging };
|