guildwars2-ts 1.1.2 → 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/LICENSE +16 -16
- package/README.md +1 -10
- package/dist/index.d.mts +165 -26
- package/dist/index.d.ts +165 -26
- package/dist/index.js +270 -24
- package/dist/index.mjs +270 -24
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -70,13 +70,10 @@ var ApiTimeoutError = class _ApiTimeoutError extends Error {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
73
|
-
LogLevel2[LogLevel2["silly"] = 0] = "silly";
|
|
74
|
-
LogLevel2[LogLevel2["trace"] = 1] = "trace";
|
|
75
|
-
LogLevel2[LogLevel2["debug"] = 2] = "debug";
|
|
76
|
-
LogLevel2[LogLevel2["info"] = 3] = "info";
|
|
77
|
-
LogLevel2[LogLevel2["warn"] = 4] = "warn";
|
|
78
73
|
LogLevel2[LogLevel2["error"] = 5] = "error";
|
|
79
|
-
LogLevel2[LogLevel2["
|
|
74
|
+
LogLevel2[LogLevel2["warn"] = 4] = "warn";
|
|
75
|
+
LogLevel2[LogLevel2["info"] = 3] = "info";
|
|
76
|
+
LogLevel2[LogLevel2["debug"] = 2] = "debug";
|
|
80
77
|
return LogLevel2;
|
|
81
78
|
})(LogLevel || {});
|
|
82
79
|
var logger = new tslog.Logger({
|
|
@@ -109,8 +106,7 @@ var ApiBase = class {
|
|
|
109
106
|
constructor(apiParams) {
|
|
110
107
|
this._apiToken = apiParams?.token;
|
|
111
108
|
this._language = apiParams?.language ?? "en" /* English */;
|
|
112
|
-
this._rateLimitRetry = apiParams?.
|
|
113
|
-
this._rateLimitRetryAttempts = apiParams?.rateLimit?.retry ? apiParams.rateLimit.attempts : 0;
|
|
109
|
+
this._rateLimitRetry = apiParams?.rateLimitRetry ?? true;
|
|
114
110
|
}
|
|
115
111
|
/**
|
|
116
112
|
* Parameters for the api response, at top level
|
|
@@ -119,10 +115,7 @@ var ApiBase = class {
|
|
|
119
115
|
return {
|
|
120
116
|
token: this._apiToken,
|
|
121
117
|
language: this._language,
|
|
122
|
-
|
|
123
|
-
retry: this._rateLimitRetry,
|
|
124
|
-
attempts: this._rateLimitRetryAttempts
|
|
125
|
-
}
|
|
118
|
+
rateLimitRetry: this._rateLimitRetry
|
|
126
119
|
};
|
|
127
120
|
}
|
|
128
121
|
/**
|
|
@@ -155,11 +148,11 @@ var ApiBase = class {
|
|
|
155
148
|
const parse = responseType.safeParse(data);
|
|
156
149
|
if (!parse.success) {
|
|
157
150
|
logger.warn(
|
|
158
|
-
"The requested data failed to parse, when using the known schema. Data is still returned, but may be incorrectly typed"
|
|
151
|
+
"The requested data failed to parse, when using the known schema. Data is still returned, but may be incorrectly typed. Please submit the following log to the developers:"
|
|
159
152
|
);
|
|
160
|
-
logger.warn("Please submit the following log to the developers:");
|
|
161
153
|
logger.warn(parse.error.errors);
|
|
162
154
|
}
|
|
155
|
+
logger.info(`[200] Successful request to ${endpoint.path}`);
|
|
163
156
|
return data;
|
|
164
157
|
} catch (error) {
|
|
165
158
|
return await this.retryRequest(endpoint, options, responseType, apiParams, attempts ?? 0, error);
|
|
@@ -180,41 +173,43 @@ var ApiBase = class {
|
|
|
180
173
|
const { status } = prevError.response;
|
|
181
174
|
switch (true) {
|
|
182
175
|
case status === 401: {
|
|
183
|
-
logger.warn(
|
|
176
|
+
logger.warn(
|
|
177
|
+
// biome-ignore lint/style/noNonNullAssertion: <This will always be present>
|
|
178
|
+
`[401] Failed request to ${prevOptions.url}. Failed to authorize with the provided token.`
|
|
179
|
+
);
|
|
184
180
|
throw new ApiTokenError();
|
|
185
181
|
}
|
|
186
182
|
case status === 403: {
|
|
187
183
|
const requiredScope = prevError.response.data.text.slice(0, 1).toUpperCase() + prevError.response.data.text.slice(1);
|
|
188
|
-
logger.warn(`
|
|
184
|
+
logger.warn(`[403] Failed request to ${prevOptions.url}. ${requiredScope}.`);
|
|
189
185
|
throw new ApiPermissionsError(requiredScope);
|
|
190
186
|
}
|
|
191
187
|
case status === 404: {
|
|
192
|
-
logger.warn(`
|
|
188
|
+
logger.warn(`[404] Failed request to ${prevOptions.url}. No data was returned.`);
|
|
193
189
|
throw new ApiNotFoundError();
|
|
194
190
|
}
|
|
195
191
|
case status === 429: {
|
|
196
192
|
if (!this._rateLimitRetry) {
|
|
197
|
-
logger.warn("Rate-limit has been reached, but retries were turned off. Stopping here.");
|
|
193
|
+
logger.warn("[429] Rate-limit has been reached, but retries were turned off. Stopping here.");
|
|
198
194
|
throw new ApiRetryFailedError();
|
|
199
195
|
}
|
|
200
196
|
if (rateLimitAttempt < 3) {
|
|
201
197
|
logger.warn(
|
|
202
198
|
// biome-ignore lint/style/noNonNullAssertion: <This will always be present>
|
|
203
|
-
`Rate-limit has been reached. Request to ${prevOptions.url} will be repeated in 30 seconds.`
|
|
199
|
+
`[429] Rate-limit has been reached. Request to ${prevOptions.url} will be repeated in 30 seconds.`
|
|
204
200
|
);
|
|
205
201
|
await new Promise((resolve) => setTimeout(() => resolve(), 3e4));
|
|
206
202
|
return await this.buildRequest(endpoint, apiParams, responseType, ++rateLimitAttempt);
|
|
207
|
-
} else {
|
|
208
|
-
logger.error(`Rate-limit retries failed. Aborting request to ${prevOptions.url}`);
|
|
209
|
-
throw new ApiRetryFailedError();
|
|
210
203
|
}
|
|
204
|
+
logger.error(`[429] Rate-limit retries failed. Aborting request to ${prevOptions.url}`);
|
|
205
|
+
throw new ApiRetryFailedError();
|
|
211
206
|
}
|
|
212
207
|
case status === 504: {
|
|
213
|
-
logger.warn(`Request to ${prevOptions.url} timed out.`);
|
|
208
|
+
logger.warn(`[504] Request to ${prevOptions.url} timed out.`);
|
|
214
209
|
throw new ApiTimeoutError();
|
|
215
210
|
}
|
|
216
211
|
default:
|
|
217
|
-
logger.warn(`Request to ${prevOptions.url} failed. ${prevError.message}`);
|
|
212
|
+
logger.warn(`[???] Request to ${prevOptions.url} failed. ${prevError.message}`);
|
|
218
213
|
throw new ApiGenericError();
|
|
219
214
|
}
|
|
220
215
|
}
|
|
@@ -592,6 +587,107 @@ var AccountWalletDTO = zod.z.array(
|
|
|
592
587
|
value: zod.z.number()
|
|
593
588
|
})
|
|
594
589
|
);
|
|
590
|
+
var AccountWizardsVaultDailyDTO = zod.z.object({
|
|
591
|
+
/** The current progress to the meta achievement for the daily. */
|
|
592
|
+
meta_progress_current: zod.z.number(),
|
|
593
|
+
/** The threshold for the meta progress to be 'complete', and the meta reward claimable. */
|
|
594
|
+
meta_progress_complete: zod.z.number(),
|
|
595
|
+
/** The ID of the item you receive for claiming the meta reward */
|
|
596
|
+
meta_reward_item_id: zod.z.number(),
|
|
597
|
+
/** The amount of Astral Acclaim you receive for claiming the meta reward */
|
|
598
|
+
meta_reward_astral: zod.z.number(),
|
|
599
|
+
/** Whether the account has claimed the meta reward. */
|
|
600
|
+
meta_reward_claimed: zod.z.boolean(),
|
|
601
|
+
/** An array of objects detailing each daily objective */
|
|
602
|
+
objectives: zod.z.array(
|
|
603
|
+
zod.z.object({
|
|
604
|
+
/** The ID of the objective. */
|
|
605
|
+
id: zod.z.number(),
|
|
606
|
+
/** The title of the objective. */
|
|
607
|
+
title: zod.z.string(),
|
|
608
|
+
/** The reward track containing the objective. */
|
|
609
|
+
track: zod.z.string(),
|
|
610
|
+
/** The astral acclaim awarded for the objective. */
|
|
611
|
+
acclaim: zod.z.number(),
|
|
612
|
+
/** The current progress of the objective. */
|
|
613
|
+
progress_current: zod.z.number(),
|
|
614
|
+
/** The progress status of the objective. */
|
|
615
|
+
progress_complete: zod.z.number(),
|
|
616
|
+
/** The claim status of the objective. */
|
|
617
|
+
claimed: zod.z.boolean()
|
|
618
|
+
})
|
|
619
|
+
)
|
|
620
|
+
});
|
|
621
|
+
var AccountWizardsVaultListingsDTO = zod.z.array(
|
|
622
|
+
zod.z.object({
|
|
623
|
+
/** The listing id. */
|
|
624
|
+
id: zod.z.number(),
|
|
625
|
+
/** The id of the item */
|
|
626
|
+
item_id: zod.z.number(),
|
|
627
|
+
/** The quantity of the item the user receives */
|
|
628
|
+
item_count: zod.z.number(),
|
|
629
|
+
/** Appears to be the position in the wizards vault UI. */
|
|
630
|
+
type: zod.z.enum(["Featured", "Normal", "Legacy"]),
|
|
631
|
+
/** The quantity of Astral Acclaim to purchase . */
|
|
632
|
+
cost: zod.z.number(),
|
|
633
|
+
/** Amount of the item already purchased. Not included if the reward is unlimited. */
|
|
634
|
+
purchased: zod.z.number().optional(),
|
|
635
|
+
/** Maximum amount that can be purchased. Not included if the reward is unlimited. */
|
|
636
|
+
purchase_limit: zod.z.number().optional()
|
|
637
|
+
})
|
|
638
|
+
);
|
|
639
|
+
var AccountWizardsVaultSpecialDTO = zod.z.object({
|
|
640
|
+
/** An array of objects detailing each weekly objective */
|
|
641
|
+
objectives: zod.z.array(
|
|
642
|
+
zod.z.object({
|
|
643
|
+
/** The ID of the objective. */
|
|
644
|
+
id: zod.z.number(),
|
|
645
|
+
/** The title of the objective. */
|
|
646
|
+
title: zod.z.string(),
|
|
647
|
+
/** The reward track containing the objective. */
|
|
648
|
+
track: zod.z.string(),
|
|
649
|
+
/** The astral acclaim awarded for the objective. */
|
|
650
|
+
acclaim: zod.z.number(),
|
|
651
|
+
/** The current progress of the objective. */
|
|
652
|
+
progress_current: zod.z.number(),
|
|
653
|
+
/** The progress status of the objective. */
|
|
654
|
+
progress_complete: zod.z.number(),
|
|
655
|
+
/** The claim status of the objective. */
|
|
656
|
+
claimed: zod.z.boolean()
|
|
657
|
+
})
|
|
658
|
+
)
|
|
659
|
+
});
|
|
660
|
+
var AccountWizardsVaultWeeklyDTO = zod.z.object({
|
|
661
|
+
/** The current progress to the meta achievement for the weekly. */
|
|
662
|
+
meta_progress_current: zod.z.number(),
|
|
663
|
+
/** The threshold for the meta progress to be 'complete', and the meta reward claimable. */
|
|
664
|
+
meta_progress_complete: zod.z.number(),
|
|
665
|
+
/** The ID of the item you receive for claiming the meta reward */
|
|
666
|
+
meta_reward_item_id: zod.z.number(),
|
|
667
|
+
/** The amount of Astral Acclaim you receive for claiming the meta reward */
|
|
668
|
+
meta_reward_astral: zod.z.number(),
|
|
669
|
+
/** Whether the account has claimed the meta reward. */
|
|
670
|
+
meta_reward_claimed: zod.z.boolean(),
|
|
671
|
+
/** An array of objects detailing each weekly objective */
|
|
672
|
+
objectives: zod.z.array(
|
|
673
|
+
zod.z.object({
|
|
674
|
+
/** The ID of the objective. */
|
|
675
|
+
id: zod.z.number(),
|
|
676
|
+
/** The title of the objective. */
|
|
677
|
+
title: zod.z.string(),
|
|
678
|
+
/** The reward track containing the objective. */
|
|
679
|
+
track: zod.z.string(),
|
|
680
|
+
/** The astral acclaim awarded for the objective. */
|
|
681
|
+
acclaim: zod.z.number(),
|
|
682
|
+
/** The current progress of the objective. */
|
|
683
|
+
progress_current: zod.z.number(),
|
|
684
|
+
/** The progress status of the objective. */
|
|
685
|
+
progress_complete: zod.z.number(),
|
|
686
|
+
/** The claim status of the objective. */
|
|
687
|
+
claimed: zod.z.boolean()
|
|
688
|
+
})
|
|
689
|
+
)
|
|
690
|
+
});
|
|
595
691
|
var AccountWorldBossesDTO = zod.z.array(
|
|
596
692
|
/** Name of the world boss. */
|
|
597
693
|
zod.z.string()
|
|
@@ -3643,6 +3739,44 @@ var StoriesSeasonsDTO = zod.z.array(
|
|
|
3643
3739
|
stories: zod.z.array(zod.z.number())
|
|
3644
3740
|
})
|
|
3645
3741
|
);
|
|
3742
|
+
var WizardsVaultDTO = zod.z.object({
|
|
3743
|
+
/** The name of the current season. */
|
|
3744
|
+
title: zod.z.string(),
|
|
3745
|
+
/** The date that the current season begins. */
|
|
3746
|
+
start: zod.z.string(),
|
|
3747
|
+
/** The date that the current season ends. */
|
|
3748
|
+
end: zod.z.string(),
|
|
3749
|
+
/** The wizard's vault listing ids available (use the sub endpoint to view item details). */
|
|
3750
|
+
listings: zod.z.array(zod.z.number()),
|
|
3751
|
+
/** The wizard's vault objective ids available (use the sub endpoint to view item details). */
|
|
3752
|
+
objectives: zod.z.array(zod.z.number())
|
|
3753
|
+
});
|
|
3754
|
+
var WizardsVaultListingsDTO = zod.z.array(
|
|
3755
|
+
zod.z.object({
|
|
3756
|
+
/** The listing id. */
|
|
3757
|
+
id: zod.z.number(),
|
|
3758
|
+
/** The id of the item */
|
|
3759
|
+
item_id: zod.z.number(),
|
|
3760
|
+
/** The quantity of the item the user receives */
|
|
3761
|
+
item_count: zod.z.number(),
|
|
3762
|
+
/** Appears to be the position in the wizards vault UI. */
|
|
3763
|
+
type: zod.z.enum(["Featured", "Normal", "Legacy"]),
|
|
3764
|
+
/** The quantity of Astral Acclaim to purchase . */
|
|
3765
|
+
cost: zod.z.number()
|
|
3766
|
+
})
|
|
3767
|
+
);
|
|
3768
|
+
var WizardsVaultObjectivesDTO = zod.z.array(
|
|
3769
|
+
zod.z.object({
|
|
3770
|
+
/** The ID of the objective. */
|
|
3771
|
+
id: zod.z.number(),
|
|
3772
|
+
/** The title of the objective. */
|
|
3773
|
+
title: zod.z.string(),
|
|
3774
|
+
/** The reward track containing the objective. */
|
|
3775
|
+
track: zod.z.enum(["PvP", "WvW", "PvE"]),
|
|
3776
|
+
/** The amount of astral acclaim awarded. */
|
|
3777
|
+
acclaim: zod.z.number()
|
|
3778
|
+
})
|
|
3779
|
+
);
|
|
3646
3780
|
var WvWAbilitiesDTO = zod.z.array(
|
|
3647
3781
|
zod.z.object({
|
|
3648
3782
|
/** The id of the abilities.*/
|
|
@@ -4032,6 +4166,22 @@ var endpoints = {
|
|
|
4032
4166
|
path: "v2/account/wallet",
|
|
4033
4167
|
tokenRequired: true
|
|
4034
4168
|
},
|
|
4169
|
+
wizardsVaultDaily: {
|
|
4170
|
+
path: "v2/account/wizardsvault/daily",
|
|
4171
|
+
tokenRequired: true
|
|
4172
|
+
},
|
|
4173
|
+
wizardsVaultListings: {
|
|
4174
|
+
path: "v2/account/wizardsvault/listings",
|
|
4175
|
+
tokenRequired: true
|
|
4176
|
+
},
|
|
4177
|
+
wizardsVaultSpecial: {
|
|
4178
|
+
path: "v2/account/wizardsvault/special",
|
|
4179
|
+
tokenRequired: true
|
|
4180
|
+
},
|
|
4181
|
+
wizardsVaultWeekly: {
|
|
4182
|
+
path: "v2/account/wizardsvault/weekly",
|
|
4183
|
+
tokenRequired: true
|
|
4184
|
+
},
|
|
4035
4185
|
worldBosses: {
|
|
4036
4186
|
path: "v2/account/worldbosses",
|
|
4037
4187
|
tokenRequired: true
|
|
@@ -4700,6 +4850,28 @@ var endpoints = {
|
|
|
4700
4850
|
tokenRequired: false
|
|
4701
4851
|
}
|
|
4702
4852
|
},
|
|
4853
|
+
wizardsVault: {
|
|
4854
|
+
root: {
|
|
4855
|
+
path: "v2/wizardsvault",
|
|
4856
|
+
tokenRequired: false
|
|
4857
|
+
},
|
|
4858
|
+
listingsAll: {
|
|
4859
|
+
path: "v2/wizardsvault/listings",
|
|
4860
|
+
tokenRequired: false
|
|
4861
|
+
},
|
|
4862
|
+
listingsById: {
|
|
4863
|
+
path: "v2/wizardsvault/listings?ids=$(ids)",
|
|
4864
|
+
tokenRequired: false
|
|
4865
|
+
},
|
|
4866
|
+
objectivesAll: {
|
|
4867
|
+
path: "v2/wizardsvault/objectives",
|
|
4868
|
+
tokenRequired: false
|
|
4869
|
+
},
|
|
4870
|
+
objectivesById: {
|
|
4871
|
+
path: "v2/wizardsvault/objectives?ids=$(ids)",
|
|
4872
|
+
tokenRequired: false
|
|
4873
|
+
}
|
|
4874
|
+
},
|
|
4703
4875
|
worldBosses: {
|
|
4704
4876
|
path: "v2/worldbosses",
|
|
4705
4877
|
tokenRequired: false
|
|
@@ -5040,6 +5212,46 @@ var AccountApi = class extends ApiBase {
|
|
|
5040
5212
|
async getWallet() {
|
|
5041
5213
|
return await this.buildRequest(endpoints.account.wallet, {}, AccountWalletDTO);
|
|
5042
5214
|
}
|
|
5215
|
+
/**
|
|
5216
|
+
* Returns the current set of daily Wizard's Vault achievements for the account.
|
|
5217
|
+
*/
|
|
5218
|
+
async getWizardsVaultDaily() {
|
|
5219
|
+
return await this.buildRequest(
|
|
5220
|
+
endpoints.account.wizardsVaultDaily,
|
|
5221
|
+
{},
|
|
5222
|
+
AccountWizardsVaultDailyDTO
|
|
5223
|
+
);
|
|
5224
|
+
}
|
|
5225
|
+
/**
|
|
5226
|
+
* 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.
|
|
5227
|
+
*/
|
|
5228
|
+
async getWizardsVaultListings() {
|
|
5229
|
+
return await this.buildRequest(
|
|
5230
|
+
endpoints.account.wizardsVaultListings,
|
|
5231
|
+
{},
|
|
5232
|
+
AccountWizardsVaultListingsDTO
|
|
5233
|
+
);
|
|
5234
|
+
}
|
|
5235
|
+
/**
|
|
5236
|
+
* Returns the current set of special Wizard's Vault achievements for the account.
|
|
5237
|
+
*/
|
|
5238
|
+
async getWizardsVaultSpecial() {
|
|
5239
|
+
return await this.buildRequest(
|
|
5240
|
+
endpoints.account.wizardsVaultSpecial,
|
|
5241
|
+
{},
|
|
5242
|
+
AccountWizardsVaultSpecialDTO
|
|
5243
|
+
);
|
|
5244
|
+
}
|
|
5245
|
+
/**
|
|
5246
|
+
* Returns the current set of weekly Wizard's Vault achievements for the account.
|
|
5247
|
+
*/
|
|
5248
|
+
async getWizardsVaultWeekly() {
|
|
5249
|
+
return await this.buildRequest(
|
|
5250
|
+
endpoints.account.wizardsVaultWeekly,
|
|
5251
|
+
{},
|
|
5252
|
+
AccountWizardsVaultWeeklyDTO
|
|
5253
|
+
);
|
|
5254
|
+
}
|
|
5043
5255
|
/**
|
|
5044
5256
|
* Returns information about which world bosses have been killed by the account since daily-reset.
|
|
5045
5257
|
*/
|
|
@@ -6105,6 +6317,38 @@ var PvPApi = class extends ApiBase {
|
|
|
6105
6317
|
}
|
|
6106
6318
|
};
|
|
6107
6319
|
|
|
6320
|
+
// src/apis/wizardsvault/wizardsvault.ts
|
|
6321
|
+
var WizardsVaultApi = class extends ApiBase {
|
|
6322
|
+
/**
|
|
6323
|
+
* Returns information about the current Wizard's Vault season.
|
|
6324
|
+
*/
|
|
6325
|
+
async get() {
|
|
6326
|
+
return await this.buildRequest(endpoints.wizardsVault.root, {}, WizardsVaultDTO);
|
|
6327
|
+
}
|
|
6328
|
+
async getListings(ids) {
|
|
6329
|
+
if (ids)
|
|
6330
|
+
return await this.buildRequest(
|
|
6331
|
+
endpoints.wizardsVault.listingsById,
|
|
6332
|
+
{ ids },
|
|
6333
|
+
WizardsVaultListingsDTO
|
|
6334
|
+
);
|
|
6335
|
+
return await this.buildRequest(endpoints.wizardsVault.listingsAll, {}, numberArrayType);
|
|
6336
|
+
}
|
|
6337
|
+
async getObjectives(ids) {
|
|
6338
|
+
if (ids)
|
|
6339
|
+
return await this.buildRequest(
|
|
6340
|
+
endpoints.wizardsVault.objectivesById,
|
|
6341
|
+
{ ids },
|
|
6342
|
+
WizardsVaultObjectivesDTO
|
|
6343
|
+
);
|
|
6344
|
+
return await this.buildRequest(
|
|
6345
|
+
endpoints.wizardsVault.objectivesAll,
|
|
6346
|
+
{},
|
|
6347
|
+
numberArrayType
|
|
6348
|
+
);
|
|
6349
|
+
}
|
|
6350
|
+
};
|
|
6351
|
+
|
|
6108
6352
|
// src/apis/wvw/wvw.ts
|
|
6109
6353
|
var WorldVsWorldApi = class extends ApiBase {
|
|
6110
6354
|
async getAbilities(ids) {
|
|
@@ -6280,6 +6524,8 @@ var GW2Api = class extends ApiBase {
|
|
|
6280
6524
|
tokenInfo = new TokenInfoApi(this.getParams());
|
|
6281
6525
|
/** /v2/traits Api */
|
|
6282
6526
|
traits = new TraitsApi(this.getParams());
|
|
6527
|
+
/** /v2/wizardsvault Api */
|
|
6528
|
+
wizardsVault = new WizardsVaultApi(this.getParams());
|
|
6283
6529
|
/** /v2/worldbosses Api */
|
|
6284
6530
|
worldBosses = new WorldBossesApi(this.getParams());
|
|
6285
6531
|
/** /v2/worlds Api */
|