@wynnjs/api 3.0.0

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/dist/index.cjs ADDED
@@ -0,0 +1,1804 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+ var zod = require('zod');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
9
+
10
+ // src/client.ts
11
+
12
+ // src/auth.ts
13
+ function authHeaders(auth) {
14
+ if (!auth) {
15
+ return {};
16
+ }
17
+ switch (auth.type) {
18
+ case "token":
19
+ return { Authorization: `Bearer ${auth.token}` };
20
+ case "oauth":
21
+ return { Authorization: `Bearer ${auth.accessToken}` };
22
+ case "session":
23
+ return { Cookie: auth.cookie };
24
+ }
25
+ }
26
+
27
+ // src/constants.ts
28
+ var API_BASE_URL = "https://api.wynncraft.com/v3";
29
+ var WYNNCRAFT_API_VERSION = "3.7.2";
30
+ var CDN_BASE_URL = "https://cdn.wynncraft.com";
31
+ function assetUrl(path) {
32
+ return `${CDN_BASE_URL}/${path.replace(/^\//, "")}`;
33
+ }
34
+ var MultipleObjectsEntrySchema = zod.z.object({
35
+ username: zod.z.string().optional(),
36
+ name: zod.z.string().optional(),
37
+ prefix: zod.z.string().optional(),
38
+ uuid: zod.z.uuid().optional(),
39
+ rank: zod.z.string().optional(),
40
+ supportRank: zod.z.string().nullable().optional(),
41
+ shortenedRank: zod.z.string().nullable().optional(),
42
+ legacyRankColour: zod.z.object({
43
+ main: zod.z.string(),
44
+ sub: zod.z.string()
45
+ }).optional(),
46
+ rankBadge: zod.z.string().optional()
47
+ }).passthrough();
48
+ var MultipleObjectsMapSchema = zod.z.record(zod.z.string(), MultipleObjectsEntrySchema);
49
+ var MultipleObjectsReturnedBodySchema = zod.z.object({
50
+ error: zod.z.literal("MultipleObjectsReturned"),
51
+ detail: zod.z.string(),
52
+ code: zod.z.literal(300),
53
+ identifier: zod.z.string().optional(),
54
+ objects: MultipleObjectsMapSchema
55
+ });
56
+
57
+ // src/errors.ts
58
+ var WynnApiErrorBodySchema = zod.z.object({
59
+ error: zod.z.string(),
60
+ detail: zod.z.string(),
61
+ code: zod.z.number(),
62
+ identifier: zod.z.string().optional(),
63
+ objects: MultipleObjectsMapSchema.optional()
64
+ });
65
+ exports.WynnApiError = class WynnApiError extends Error {
66
+ name = "WynnApiError";
67
+ /** Machine-readable error name from the API, e.g. `NotFound`. */
68
+ error;
69
+ /** Human-readable error message from the API. */
70
+ detail;
71
+ /** Wynncraft error code. */
72
+ code;
73
+ /** Optional identifier for the resource that caused the error. */
74
+ identifier;
75
+ /** Present on {@link WynnApiError.MultipleObjectsReturned} errors. */
76
+ objects;
77
+ /** HTTP status code from the response. */
78
+ status;
79
+ /**
80
+ * @param body - Parsed Wynncraft error response body.
81
+ * @param status - HTTP status code from the response.
82
+ */
83
+ constructor(body, status) {
84
+ super(body.detail);
85
+ this.error = body.error;
86
+ this.detail = body.detail;
87
+ this.code = body.code;
88
+ this.identifier = body.identifier;
89
+ this.objects = body.objects;
90
+ this.status = status;
91
+ }
92
+ };
93
+ function wynnErrorClass(errorName) {
94
+ return class extends exports.WynnApiError {
95
+ name = errorName;
96
+ };
97
+ }
98
+ var MultipleObjectsReturnedError = class extends exports.WynnApiError {
99
+ name = "MultipleObjectsReturned";
100
+ objects;
101
+ constructor(body, status) {
102
+ super(body, status);
103
+ this.objects = body.objects;
104
+ }
105
+ };
106
+ ((WynnApiError2) => {
107
+ WynnApiError2.MultipleObjectsReturned = MultipleObjectsReturnedError;
108
+ WynnApiError2.InvalidFormError = wynnErrorClass("InvalidFormError");
109
+ WynnApiError2.InvalidQueryParamsError = wynnErrorClass("InvalidQueryParamsError");
110
+ WynnApiError2.MalformedPayload = wynnErrorClass("MalformedPayload");
111
+ WynnApiError2.MalformedTokenError = wynnErrorClass("MalformedTokenError");
112
+ WynnApiError2.CSRFError = wynnErrorClass("CSRFError");
113
+ WynnApiError2.InvalidTokenError = wynnErrorClass("InvalidTokenError");
114
+ WynnApiError2.PaginationError = wynnErrorClass("PaginationError");
115
+ WynnApiError2.Forbidden = wynnErrorClass("Forbidden");
116
+ WynnApiError2.NotFound = wynnErrorClass("NotFound");
117
+ WynnApiError2.MethodNotAllowed = wynnErrorClass("MethodNotAllowed");
118
+ WynnApiError2.TooManyRequest = wynnErrorClass("TooManyRequest");
119
+ WynnApiError2.InternalError = wynnErrorClass("InternalError");
120
+ WynnApiError2.InvalidCharacterUUID = wynnErrorClass("InvalidCharacterUUID");
121
+ WynnApiError2.NoCharacterFound = wynnErrorClass("NoCharacterFound");
122
+ WynnApiError2.MalformedPrefixError = wynnErrorClass("MalformedPrefixError");
123
+ WynnApiError2.InvalidTree = wynnErrorClass("InvalidTree");
124
+ })(exports.WynnApiError || (exports.WynnApiError = {}));
125
+ var WYNN_ERROR_REGISTRY = {
126
+ MultipleObjectsReturned: exports.WynnApiError.MultipleObjectsReturned,
127
+ InvalidFormError: exports.WynnApiError.InvalidFormError,
128
+ InvalidQueryParamsError: exports.WynnApiError.InvalidQueryParamsError,
129
+ MalformedPayload: exports.WynnApiError.MalformedPayload,
130
+ MalformedTokenError: exports.WynnApiError.MalformedTokenError,
131
+ CSRFError: exports.WynnApiError.CSRFError,
132
+ InvalidTokenError: exports.WynnApiError.InvalidTokenError,
133
+ PaginationError: exports.WynnApiError.PaginationError,
134
+ Forbidden: exports.WynnApiError.Forbidden,
135
+ NotFound: exports.WynnApiError.NotFound,
136
+ MethodNotAllowed: exports.WynnApiError.MethodNotAllowed,
137
+ TooManyRequest: exports.WynnApiError.TooManyRequest,
138
+ InternalError: exports.WynnApiError.InternalError,
139
+ InvalidCharacterUUID: exports.WynnApiError.InvalidCharacterUUID,
140
+ NoCharacterFound: exports.WynnApiError.NoCharacterFound,
141
+ MalformedPrefixError: exports.WynnApiError.MalformedPrefixError,
142
+ InvalidTree: exports.WynnApiError.InvalidTree
143
+ };
144
+ function createWynnApiError(body, status) {
145
+ if (body.error === "MultipleObjectsReturned") {
146
+ const parsed = MultipleObjectsReturnedBodySchema.safeParse(body);
147
+ if (parsed.success) {
148
+ return new exports.WynnApiError.MultipleObjectsReturned(parsed.data, status);
149
+ }
150
+ }
151
+ const ErrorClass = WYNN_ERROR_REGISTRY[body.error] ?? exports.WynnApiError;
152
+ return new ErrorClass(body, status);
153
+ }
154
+ function toWynnApiError(error) {
155
+ if (!axios__default.default.isAxiosError(error) || !error.response) {
156
+ return null;
157
+ }
158
+ const parsed = WynnApiErrorBodySchema.safeParse(error.response.data);
159
+ if (!parsed.success) {
160
+ return null;
161
+ }
162
+ return createWynnApiError(parsed.data, error.response.status);
163
+ }
164
+
165
+ // src/http.ts
166
+ function serializeRequestParams(params, presenceParams) {
167
+ const searchParams = new URLSearchParams();
168
+ if (params != null && typeof params === "object" && !Array.isArray(params)) {
169
+ for (const [key, value] of Object.entries(params)) {
170
+ if (value !== void 0) {
171
+ searchParams.set(key, String(value));
172
+ }
173
+ }
174
+ }
175
+ const baseQuery = searchParams.toString();
176
+ if (!presenceParams?.length) {
177
+ return baseQuery;
178
+ }
179
+ const presenceQuery = presenceParams.map((param) => encodeURIComponent(param)).join("&");
180
+ return baseQuery ? `${baseQuery}&${presenceQuery}` : presenceQuery;
181
+ }
182
+ function toAxiosRequestConfig(config) {
183
+ const hasPresence = Boolean(config.presenceParams?.length);
184
+ return {
185
+ method: config.method ?? "GET",
186
+ url: config.path,
187
+ params: hasPresence ? config.params ?? {} : config.params,
188
+ paramsSerializer: hasPresence ? (params) => serializeRequestParams(params, config.presenceParams) : void 0,
189
+ data: config.data,
190
+ headers: config.headers
191
+ };
192
+ }
193
+ function parseRateLimit(headers) {
194
+ const bucket = headers.get("ratelimit-bucket");
195
+ const limit = headers.get("ratelimit-limit");
196
+ const remaining = headers.get("ratelimit-remaining");
197
+ const reset = headers.get("ratelimit-reset");
198
+ if (!bucket || !limit || !remaining || !reset) {
199
+ return null;
200
+ }
201
+ return {
202
+ bucket: String(bucket),
203
+ limit: Number(limit),
204
+ remaining: Number(remaining),
205
+ reset: Number(reset)
206
+ };
207
+ }
208
+ var ClassTreeSchema = zod.z.enum(["archer", "warrior", "assassin", "mage", "shaman"]);
209
+ var AbilityIconValueCustomModelDataSchema = zod.z.object({
210
+ rangeDispatch: zod.z.array(zod.z.number())
211
+ });
212
+ var AbilityIconValueSchema = zod.z.object({
213
+ id: zod.z.string(),
214
+ name: zod.z.string(),
215
+ customModelData: AbilityIconValueCustomModelDataSchema
216
+ });
217
+ var AbilityIconSchema = zod.z.object({
218
+ name: zod.z.string().optional(),
219
+ value: AbilityIconValueSchema,
220
+ format: zod.z.string()
221
+ });
222
+ var AbilityMapNodeCoordinatesSchema = zod.z.object({
223
+ x: zod.z.number(),
224
+ y: zod.z.number()
225
+ });
226
+ var AbilityMapNodeMetaIconSchema = zod.z.union([AbilityIconSchema, zod.z.string()]);
227
+ var AbilityMapNodeMetaSchema = zod.z.object({
228
+ icon: AbilityMapNodeMetaIconSchema.optional(),
229
+ page: zod.z.number(),
230
+ id: zod.z.string().optional()
231
+ });
232
+ var AbilityMapNodeSchema = zod.z.object({
233
+ type: zod.z.enum(["ability", "connector"]),
234
+ coordinates: AbilityMapNodeCoordinatesSchema,
235
+ meta: AbilityMapNodeMetaSchema,
236
+ family: zod.z.array(zod.z.string())
237
+ });
238
+ var AbilityMapPagesSchema = zod.z.record(zod.z.string(), zod.z.array(AbilityMapNodeSchema));
239
+
240
+ // src/schemas/ability/get-ability-map.ts
241
+ var GetAbilityMapResultSchema = AbilityMapPagesSchema;
242
+ var AbilityTreeArchetypeSchema = zod.z.object({
243
+ name: zod.z.string(),
244
+ description: zod.z.string(),
245
+ shortDescription: zod.z.string(),
246
+ icon: AbilityIconSchema,
247
+ slot: zod.z.number()
248
+ });
249
+ var AbilityDefinitionSchema = zod.z.object({
250
+ name: zod.z.string(),
251
+ icon: AbilityIconSchema,
252
+ slot: zod.z.number(),
253
+ coordinates: zod.z.object({
254
+ x: zod.z.number(),
255
+ y: zod.z.number()
256
+ }),
257
+ description: zod.z.array(zod.z.string()),
258
+ requirements: zod.z.record(zod.z.string(), zod.z.number()),
259
+ links: zod.z.array(zod.z.string()),
260
+ locks: zod.z.array(zod.z.string()).nullable(),
261
+ page: zod.z.number()
262
+ });
263
+ var GetAbilityTreeResultSchema = zod.z.object({
264
+ archetypes: zod.z.record(zod.z.string(), AbilityTreeArchetypeSchema),
265
+ pages: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), AbilityDefinitionSchema))
266
+ });
267
+ var AspectTierSchema = zod.z.object({
268
+ threshold: zod.z.number(),
269
+ description: zod.z.array(zod.z.string())
270
+ });
271
+ var AspectSchema = zod.z.object({
272
+ name: zod.z.string(),
273
+ internalName: zod.z.string(),
274
+ icon: AbilityIconSchema,
275
+ rarity: zod.z.string(),
276
+ requiredClass: zod.z.string(),
277
+ tiers: zod.z.record(zod.z.string(), AspectTierSchema)
278
+ });
279
+ var ListAspectsResultSchema = zod.z.array(AspectSchema);
280
+
281
+ // src/modules/ability.ts
282
+ var AbilityModule = class {
283
+ constructor(client) {
284
+ this.client = client;
285
+ }
286
+ client;
287
+ /**
288
+ * Fetch the ability tree layout for a class.
289
+ *
290
+ * @param tree - Class tree: `archer`, `warrior`, `assassin`, `mage`, or `shaman`.
291
+ * @returns Ability tree nodes and connections.
292
+ */
293
+ async getTree(tree) {
294
+ return this.client.request({
295
+ path: `/ability/tree/${encodeURIComponent(tree)}`
296
+ });
297
+ }
298
+ /**
299
+ * Fetch the ability map for a class.
300
+ *
301
+ * @param tree - Class tree: `archer`, `warrior`, `assassin`, `mage`, or `shaman`.
302
+ * @returns Ability map keyed by page.
303
+ */
304
+ async getMap(tree) {
305
+ return this.client.request({
306
+ path: `/ability/map/${encodeURIComponent(tree)}`
307
+ });
308
+ }
309
+ /**
310
+ * List all aspects for a class tree.
311
+ *
312
+ * @param tree - Class tree: `archer`, `warrior`, `assassin`, `mage`, or `shaman`.
313
+ * @returns Aspect definitions for the given tree.
314
+ */
315
+ async listAspects(tree) {
316
+ return this.client.request({
317
+ path: `/aspects/${encodeURIComponent(tree)}`
318
+ });
319
+ }
320
+ };
321
+ var ClassNameSchema = ClassTreeSchema;
322
+ var ClassArchetypeSchema = zod.z.object({
323
+ name: zod.z.string(),
324
+ difficulty: zod.z.number(),
325
+ max: zod.z.number(),
326
+ icon: zod.z.string(),
327
+ damage: zod.z.number(),
328
+ defence: zod.z.number(),
329
+ range: zod.z.number(),
330
+ speed: zod.z.number()
331
+ });
332
+ var GetClassResultSchema = zod.z.object({
333
+ id: zod.z.string(),
334
+ name: zod.z.string(),
335
+ lore: zod.z.string(),
336
+ overallDifficulty: zod.z.number(),
337
+ overallMax: zod.z.number(),
338
+ archetypes: zod.z.record(zod.z.string(), ClassArchetypeSchema)
339
+ });
340
+ var ClassSummarySchema = zod.z.object({
341
+ name: zod.z.string(),
342
+ overallDifficulty: zod.z.number()
343
+ });
344
+ var ListClassesResultSchema = zod.z.record(zod.z.string(), ClassSummarySchema);
345
+
346
+ // src/modules/classes.ts
347
+ var ClassesModule = class {
348
+ constructor(client) {
349
+ this.client = client;
350
+ }
351
+ client;
352
+ /** @returns All playable classes. */
353
+ async list() {
354
+ return this.client.request({
355
+ path: "/classes"
356
+ });
357
+ }
358
+ /**
359
+ * Fetch metadata for a single class.
360
+ *
361
+ * @param className - Class identifier, e.g. `mage` or `warrior`.
362
+ * @returns Class stats, archetypes, and weapon types.
363
+ */
364
+ async getClass(className) {
365
+ return this.client.request({
366
+ path: `/classes/${encodeURIComponent(className)}`
367
+ });
368
+ }
369
+ };
370
+ var GetGuildOptionsSchema = zod.z.object({
371
+ identifier: zod.z.enum(["username", "uuid"]).optional()
372
+ });
373
+ var CountListSchema = zod.z.object({
374
+ total: zod.z.number(),
375
+ list: zod.z.record(zod.z.string(), zod.z.number())
376
+ });
377
+ var PvpStatsSchema = zod.z.object({
378
+ kills: zod.z.number().optional(),
379
+ deaths: zod.z.number().optional()
380
+ });
381
+ var GuildMemberWeeklySchema = zod.z.object({
382
+ completed: zod.z.boolean().optional(),
383
+ streak: zod.z.number().optional()
384
+ });
385
+ var GuildMemberGlobalDataSchema = zod.z.object({
386
+ contentCompletion: zod.z.number(),
387
+ wars: zod.z.number(),
388
+ totalLevel: zod.z.number(),
389
+ mobsKilled: zod.z.number(),
390
+ chestsFound: zod.z.number(),
391
+ dungeons: CountListSchema,
392
+ raids: CountListSchema,
393
+ worldEvents: zod.z.number(),
394
+ lootruns: zod.z.number(),
395
+ caves: zod.z.number(),
396
+ completedQuests: zod.z.number(),
397
+ pvp: PvpStatsSchema,
398
+ currentGuildRaids: CountListSchema.nullable().optional(),
399
+ guildRaids: CountListSchema.nullable().optional(),
400
+ playtime: zod.z.number().optional()
401
+ });
402
+ var GuildMemberRestrictionsSchema = zod.z.object({
403
+ online_status: zod.z.boolean().optional(),
404
+ main_access: zod.z.boolean().optional(),
405
+ guild_high_ranked_access: zod.z.boolean().optional()
406
+ });
407
+ var GuildMemberSchema = zod.z.object({
408
+ uuid: zod.z.uuid().optional(),
409
+ username: zod.z.string().optional(),
410
+ online: zod.z.boolean(),
411
+ lastJoin: zod.z.string().nullable(),
412
+ server: zod.z.string().nullable(),
413
+ contributed: zod.z.number(),
414
+ contributionRank: zod.z.number(),
415
+ joined: zod.z.string(),
416
+ weekly: GuildMemberWeeklySchema,
417
+ globalData: GuildMemberGlobalDataSchema,
418
+ restrictions: GuildMemberRestrictionsSchema
419
+ });
420
+ var GuildMembersSchema = zod.z.object({
421
+ total: zod.z.number(),
422
+ owner: zod.z.record(zod.z.string(), GuildMemberSchema).optional(),
423
+ chief: zod.z.record(zod.z.string(), GuildMemberSchema).optional(),
424
+ strategist: zod.z.record(zod.z.string(), GuildMemberSchema).optional(),
425
+ recruiter: zod.z.record(zod.z.string(), GuildMemberSchema).optional(),
426
+ recruit: zod.z.record(zod.z.string(), GuildMemberSchema).optional()
427
+ });
428
+ var BannerLayerSchema = zod.z.object({
429
+ color: zod.z.string(),
430
+ pattern: zod.z.string()
431
+ });
432
+ var GuildBannerSchema = zod.z.object({
433
+ base: zod.z.string(),
434
+ tier: zod.z.number(),
435
+ structure: zod.z.string(),
436
+ layers: zod.z.array(BannerLayerSchema)
437
+ });
438
+ var GuildSeasonRankSchema = zod.z.object({
439
+ rating: zod.z.number(),
440
+ finalTerritories: zod.z.number()
441
+ });
442
+ var GuildResultSchema = zod.z.object({
443
+ uuid: zod.z.uuid(),
444
+ name: zod.z.string(),
445
+ prefix: zod.z.string(),
446
+ level: zod.z.number(),
447
+ xpPercent: zod.z.number(),
448
+ territories: zod.z.number(),
449
+ wars: zod.z.number(),
450
+ raids: zod.z.number(),
451
+ created: zod.z.string(),
452
+ members: GuildMembersSchema,
453
+ online: zod.z.number(),
454
+ banner: GuildBannerSchema,
455
+ seasonRanks: zod.z.record(zod.z.string(), GuildSeasonRankSchema),
456
+ ranking: zod.z.record(zod.z.string(), zod.z.number())
457
+ });
458
+ var ListGuildsOptionsSchema = zod.z.object({
459
+ identifier: zod.z.enum(["username", "uuid"]).optional()
460
+ });
461
+ var GuildListEntryByNameSchema = zod.z.object({
462
+ uuid: zod.z.uuid(),
463
+ prefix: zod.z.string()
464
+ });
465
+ var GuildListEntryByUuidSchema = zod.z.object({
466
+ name: zod.z.string(),
467
+ prefix: zod.z.string()
468
+ });
469
+ var ListGuildsByNameResultSchema = zod.z.record(zod.z.string(), GuildListEntryByNameSchema);
470
+ var ListGuildsByUuidResultSchema = zod.z.record(zod.z.uuid(), GuildListEntryByUuidSchema);
471
+ var GuildSeasonRewardConditionSchema = zod.z.object({
472
+ type: zod.z.enum(["SR", "LEADERBOARD_POSITION"]),
473
+ value: zod.z.number()
474
+ });
475
+ var GuildSeasonRewardSchema = zod.z.object({
476
+ condition: GuildSeasonRewardConditionSchema,
477
+ type: zod.z.enum([
478
+ "BADGE",
479
+ "EFFECT",
480
+ "COSMETIC",
481
+ "EMERALD",
482
+ "PRIVATE_BANK_SLOT",
483
+ "PUBLIC_BANK_SLOT",
484
+ "GUILD_TOME",
485
+ "STRUCTURE"
486
+ ]),
487
+ value: zod.z.union([zod.z.number(), zod.z.string()]).nullable(),
488
+ expires: zod.z.string().nullable()
489
+ });
490
+ var GuildSeasonDefinitionSchema = zod.z.object({
491
+ initDate: zod.z.string().nullable().optional(),
492
+ endDate: zod.z.string().nullable().optional(),
493
+ territoryHoldingSrPerHour: zod.z.number(),
494
+ srPerWar: zod.z.number(),
495
+ ratingRewards: zod.z.array(GuildSeasonRewardSchema),
496
+ leaderboardRewards: zod.z.array(GuildSeasonRewardSchema)
497
+ });
498
+ var ListGuildSeasonsResultSchema = zod.z.record(zod.z.string(), GuildSeasonDefinitionSchema);
499
+ var TerritoryGuildReferenceSchema = zod.z.object({
500
+ uuid: zod.z.uuid(),
501
+ name: zod.z.string(),
502
+ prefix: zod.z.string(),
503
+ hq: zod.z.string()
504
+ });
505
+ var TerritoryResourceSchema = zod.z.object({
506
+ type: zod.z.enum(["EMERALD", "ORE", "WOOD", "FISH", "CROP"]),
507
+ generation: zod.z.number(),
508
+ stored: zod.z.number(),
509
+ limit: zod.z.number()
510
+ });
511
+ var TerritoryLocationSchema = zod.z.object({
512
+ start: zod.z.array(zod.z.number()),
513
+ end: zod.z.array(zod.z.number())
514
+ });
515
+ var TerritorySchema = zod.z.object({
516
+ guild: TerritoryGuildReferenceSchema,
517
+ acquired: zod.z.string(),
518
+ hq: zod.z.boolean(),
519
+ resources: zod.z.array(TerritoryResourceSchema),
520
+ links: zod.z.array(zod.z.string()),
521
+ treasury: zod.z.enum(["VERY_LOW", "LOW", "MEDIUM", "HIGH", "VERY_HIGH"]),
522
+ defences: zod.z.enum(["VERY_LOW", "LOW", "MEDIUM", "HIGH", "VERY_HIGH"]),
523
+ location: TerritoryLocationSchema
524
+ });
525
+ var ListGuildTerritoriesResultSchema = zod.z.record(zod.z.string(), TerritorySchema);
526
+
527
+ // src/modules/guild.ts
528
+ var GuildModule = class {
529
+ constructor(client) {
530
+ this.client = client;
531
+ }
532
+ client;
533
+ /**
534
+ * List guilds with optional filters.
535
+ *
536
+ * @param options.identifier - Lookup key for list entries: `username` or `uuid`.
537
+ * @returns Guild list keyed by the chosen identifier.
538
+ */
539
+ async listGuilds(options = {}) {
540
+ return this.client.request({
541
+ path: "/guild/list/guild",
542
+ params: options
543
+ });
544
+ }
545
+ /** @returns All guild territories. */
546
+ async listTerritories() {
547
+ return this.client.request({
548
+ path: "/guild/list/territory"
549
+ });
550
+ }
551
+ /** @returns Guild season history. */
552
+ async listSeasons() {
553
+ return this.client.request({
554
+ path: "/guild/seasons"
555
+ });
556
+ }
557
+ /**
558
+ * Fetch a guild by name.
559
+ *
560
+ * @param name - Guild name.
561
+ * @param options.identifier - Response key for members: `username` or `uuid`.
562
+ * @returns Guild profile and member data.
563
+ */
564
+ async getGuild(name, options = {}) {
565
+ return this.client.request({
566
+ path: `/guild/${encodeURIComponent(name)}`,
567
+ params: options
568
+ });
569
+ }
570
+ /**
571
+ * Fetch a guild by tag prefix.
572
+ *
573
+ * @param prefix - Guild tag prefix, e.g. `ABC`.
574
+ * @param options.identifier - Response key for members: `username` or `uuid`.
575
+ * @returns Guild profile and member data.
576
+ */
577
+ async getGuildByPrefix(prefix, options = {}) {
578
+ return this.client.request({
579
+ path: `/guild/prefix/${encodeURIComponent(prefix)}`,
580
+ params: options
581
+ });
582
+ }
583
+ /**
584
+ * Fetch a guild by UUID.
585
+ *
586
+ * @param uuid - Guild UUID.
587
+ * @param options.identifier - Response key for members: `username` or `uuid`.
588
+ * @returns Guild profile and member data.
589
+ */
590
+ async getGuildByUuid(uuid, options = {}) {
591
+ return this.client.request({
592
+ path: `/guild/uuid/${encodeURIComponent(uuid)}`,
593
+ params: options
594
+ });
595
+ }
596
+ };
597
+ var GetItemMetadataOptionsSchema = zod.z.object({
598
+ static: zod.z.boolean().optional()
599
+ });
600
+ var ItemStaticValueMapSchema = zod.z.record(zod.z.string(), zod.z.number());
601
+ var ItemMetadataSchema = zod.z.object({
602
+ filters: zod.z.object({
603
+ type: zod.z.array(zod.z.string()),
604
+ advanced: zod.z.record(zod.z.string(), zod.z.array(zod.z.string())),
605
+ tier: zod.z.record(zod.z.string(), zod.z.array(zod.z.string())),
606
+ identifications: zod.z.array(zod.z.string()),
607
+ majorIds: zod.z.array(zod.z.string()),
608
+ levelRange: zod.z.array(zod.z.number())
609
+ }),
610
+ static: ItemStaticValueMapSchema
611
+ });
612
+ var ItemStaticMetadataSchema = zod.z.object({
613
+ attackSpeed: ItemStaticValueMapSchema,
614
+ emblem: ItemStaticValueMapSchema,
615
+ gathering: ItemStaticValueMapSchema,
616
+ identifications: ItemStaticValueMapSchema,
617
+ majorIds: ItemStaticValueMapSchema,
618
+ set: ItemStaticValueMapSchema,
619
+ subType: ItemStaticValueMapSchema,
620
+ tier: ItemStaticValueMapSchema,
621
+ type: ItemStaticValueMapSchema
622
+ });
623
+ var PaginationControllerSchema = zod.z.object({
624
+ count: zod.z.number(),
625
+ current_count: zod.z.number(),
626
+ pages: zod.z.number(),
627
+ prev: zod.z.number().nullable(),
628
+ current: zod.z.number(),
629
+ next: zod.z.number().nullable()
630
+ });
631
+ var PaginatedQueryOptionsSchema = zod.z.object({
632
+ page: zod.z.number().optional(),
633
+ fullResult: zod.z.boolean().optional()
634
+ });
635
+ var PaginatedItemQueryOptionsSchema = PaginatedQueryOptionsSchema;
636
+ var PaginatedRecipeQueryOptionsSchema = PaginatedQueryOptionsSchema;
637
+
638
+ // src/schemas/item/item.ts
639
+ var IdentificationRangeSchema = zod.z.object({
640
+ min: zod.z.number(),
641
+ raw: zod.z.number(),
642
+ max: zod.z.number()
643
+ });
644
+ var IdentificationValueSchema = zod.z.union([zod.z.number(), IdentificationRangeSchema]);
645
+ var ItemSchema = zod.z.object({
646
+ displayName: zod.z.string(),
647
+ internalName: zod.z.string(),
648
+ type: zod.z.string(),
649
+ subType: zod.z.string(),
650
+ icon: zod.z.object({
651
+ value: zod.z.object({
652
+ id: zod.z.string(),
653
+ name: zod.z.string(),
654
+ customModelData: zod.z.object({
655
+ rangeDispatch: zod.z.array(zod.z.number())
656
+ })
657
+ }),
658
+ format: zod.z.string()
659
+ }),
660
+ emblem: zod.z.string(),
661
+ tier: zod.z.string(),
662
+ attackSpeed: zod.z.string().optional(),
663
+ averageDps: zod.z.number().optional(),
664
+ restriction: zod.z.string().optional(),
665
+ dropRestriction: zod.z.string().optional(),
666
+ gathering: zod.z.string().optional(),
667
+ set: zod.z.string().optional(),
668
+ elements: zod.z.array(zod.z.string()).optional(),
669
+ requirements: zod.z.object({
670
+ level: zod.z.number().optional(),
671
+ classRequirement: zod.z.string().optional(),
672
+ strength: zod.z.number().optional(),
673
+ dexterity: zod.z.number().optional(),
674
+ intelligence: zod.z.number().optional(),
675
+ defence: zod.z.number().optional(),
676
+ agility: zod.z.number().optional()
677
+ }).optional(),
678
+ majorIds: zod.z.record(zod.z.string(), zod.z.string()).optional(),
679
+ powderSlots: zod.z.number().optional(),
680
+ lore: zod.z.string().optional(),
681
+ identifications: zod.z.record(zod.z.string(), IdentificationValueSchema).optional(),
682
+ base: zod.z.record(zod.z.string(), IdentificationValueSchema).optional()
683
+ });
684
+ var ItemListSchema = zod.z.array(ItemSchema);
685
+ var PaginatedItemResponseSchema = zod.z.object({
686
+ controller: PaginationControllerSchema,
687
+ results: ItemListSchema
688
+ });
689
+
690
+ // src/schemas/item/list-items.ts
691
+ var ListItemsOptionsSchema = PaginatedItemQueryOptionsSchema;
692
+ var ListItemsResultSchema = PaginatedItemResponseSchema;
693
+ var ItemSetBonusSchema = zod.z.object({
694
+ major: zod.z.array(zod.z.string()),
695
+ minor: zod.z.record(zod.z.string(), zod.z.union([zod.z.number(), zod.z.string()]))
696
+ });
697
+ var ItemSetSchema = zod.z.object({
698
+ internalName: zod.z.string(),
699
+ bonuses: zod.z.record(zod.z.string(), ItemSetBonusSchema),
700
+ parts: zod.z.array(zod.z.string())
701
+ });
702
+ var ListItemSetsResultSchema = zod.z.record(zod.z.string(), ItemSetSchema);
703
+ var IntegerRangeSchema = zod.z.object({
704
+ minimum: zod.z.number(),
705
+ maximum: zod.z.number()
706
+ });
707
+ var RecipeSchema = zod.z.object({
708
+ internalName: zod.z.string(),
709
+ type: zod.z.string(),
710
+ skill: zod.z.string(),
711
+ level: IntegerRangeSchema,
712
+ durability: IntegerRangeSchema.optional(),
713
+ materials: zod.z.array(
714
+ zod.z.object({
715
+ item: zod.z.string(),
716
+ amount: zod.z.number()
717
+ })
718
+ ),
719
+ healthOrDamage: IntegerRangeSchema,
720
+ duration: IntegerRangeSchema.optional(),
721
+ basicDuration: IntegerRangeSchema.optional(),
722
+ sprites: zod.z.record(
723
+ zod.z.string(),
724
+ zod.z.object({
725
+ format: zod.z.string(),
726
+ value: zod.z.object({
727
+ id: zod.z.string(),
728
+ customModelData: zod.z.number(),
729
+ name: zod.z.string()
730
+ }),
731
+ name: zod.z.string()
732
+ })
733
+ ),
734
+ xp: zod.z.number()
735
+ });
736
+ var RecipeListSchema = zod.z.array(RecipeSchema);
737
+ var PaginatedRecipeResponseSchema = zod.z.object({
738
+ controller: PaginationControllerSchema,
739
+ results: RecipeListSchema
740
+ });
741
+
742
+ // src/schemas/item/list-recipes.ts
743
+ var ListRecipesOptionsSchema = PaginatedRecipeQueryOptionsSchema;
744
+ var ListRecipesResultSchema = PaginatedRecipeResponseSchema;
745
+ var QuickSearchItemsResultSchema = ItemListSchema;
746
+ var ScalarOrListSchema = zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]);
747
+ var ItemSearchRequestSchema = zod.z.object({
748
+ query: zod.z.string().nullable().optional(),
749
+ type: ScalarOrListSchema.optional(),
750
+ tier: ScalarOrListSchema.optional(),
751
+ attackSpeed: ScalarOrListSchema.optional(),
752
+ levelRange: zod.z.union([zod.z.number(), zod.z.array(zod.z.number())]).optional(),
753
+ professions: ScalarOrListSchema.optional(),
754
+ identifications: ScalarOrListSchema.optional(),
755
+ majorIds: ScalarOrListSchema.optional()
756
+ });
757
+ var SearchItemsOptionsSchema = PaginatedItemQueryOptionsSchema;
758
+ var SearchItemsResultSchema = PaginatedItemResponseSchema;
759
+ var ScalarOrListSchema2 = zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]);
760
+ var RecipeSearchRequestSchema = zod.z.object({
761
+ query: ScalarOrListSchema2.optional(),
762
+ xp: zod.z.union([zod.z.number(), zod.z.array(zod.z.number())]).optional(),
763
+ type: ScalarOrListSchema2.optional(),
764
+ skill: ScalarOrListSchema2.optional(),
765
+ materials: ScalarOrListSchema2.optional(),
766
+ level: zod.z.union([zod.z.number(), zod.z.array(zod.z.number())]).optional(),
767
+ durability: zod.z.union([zod.z.number(), zod.z.array(zod.z.number())]).optional(),
768
+ healthOrDamage: zod.z.union([zod.z.number(), zod.z.array(zod.z.number())]).optional(),
769
+ duration: zod.z.union([zod.z.number(), zod.z.array(zod.z.number())]).optional(),
770
+ basicDuration: zod.z.union([zod.z.number(), zod.z.array(zod.z.number())]).optional()
771
+ });
772
+ var SearchRecipesOptionsSchema = PaginatedRecipeQueryOptionsSchema;
773
+ var SearchRecipesResultSchema = PaginatedRecipeResponseSchema;
774
+
775
+ // src/modules/item.ts
776
+ var ItemModule = class {
777
+ constructor(client) {
778
+ this.client = client;
779
+ }
780
+ client;
781
+ /**
782
+ * List items from the item database.
783
+ *
784
+ * @param options.page - Page number for paginated results.
785
+ * @param options.fullResult - Include full item data when `true`.
786
+ * @returns Paginated item list.
787
+ */
788
+ async listItems(options = {}) {
789
+ const { page, fullResult } = options;
790
+ return this.client.request({
791
+ path: "/item/database",
792
+ params: page !== void 0 ? { page } : void 0,
793
+ presenceParams: fullResult ? ["fullResult"] : void 0
794
+ });
795
+ }
796
+ /**
797
+ * Search items with structured filters.
798
+ *
799
+ * @param filters - Search criteria such as `type`, `tier`, `levelRange`, and `identifications`.
800
+ * @param options.page - Page number for paginated results.
801
+ * @param options.fullResult - Include full item data when `true`.
802
+ * @returns Paginated matching items.
803
+ */
804
+ async searchItems(filters = {}, options = {}) {
805
+ const { page, fullResult } = options;
806
+ return this.client.request({
807
+ method: "POST",
808
+ path: "/item/search",
809
+ params: page !== void 0 ? { page } : void 0,
810
+ presenceParams: fullResult ? ["fullResult"] : void 0,
811
+ data: filters
812
+ });
813
+ }
814
+ /**
815
+ * Quick text search for items by name.
816
+ *
817
+ * @param query - Free-text item name query.
818
+ * @returns Matching items keyed by internal name.
819
+ */
820
+ async quickSearchItems(query) {
821
+ return this.client.request({
822
+ path: `/item/search/${encodeURIComponent(query)}`
823
+ });
824
+ }
825
+ /**
826
+ * List recipes from the recipe database.
827
+ *
828
+ * @param options.page - Page number for paginated results.
829
+ * @param options.fullResult - Include full recipe data when `true`.
830
+ * @returns Paginated recipe list.
831
+ */
832
+ async listRecipes(options = {}) {
833
+ const { page, fullResult } = options;
834
+ return this.client.request({
835
+ path: "/item/recipe/database",
836
+ params: page !== void 0 ? { page } : void 0,
837
+ presenceParams: fullResult ? ["full_result"] : void 0
838
+ });
839
+ }
840
+ /**
841
+ * Search recipes with structured filters.
842
+ *
843
+ * @param filters - Search criteria such as `type`, `skill`, `materials`, and `level`.
844
+ * @param options.page - Page number for paginated results.
845
+ * @param options.fullResult - Include full recipe data when `true`.
846
+ * @returns Paginated matching recipes.
847
+ */
848
+ async searchRecipes(filters = {}, options = {}) {
849
+ const { page, fullResult } = options;
850
+ return this.client.request({
851
+ method: "POST",
852
+ path: "/item/recipe/search",
853
+ params: page !== void 0 ? { page } : void 0,
854
+ presenceParams: fullResult ? ["full_result"] : void 0,
855
+ data: filters
856
+ });
857
+ }
858
+ /**
859
+ * Fetch item metadata.
860
+ *
861
+ * @param options.static - Include static value maps when `true`.
862
+ * @returns Filter definitions, tiers, and identification metadata.
863
+ */
864
+ async getMetadata(options = {}) {
865
+ return this.client.request({
866
+ path: "/item/metadata",
867
+ presenceParams: options.static ? ["static"] : void 0
868
+ });
869
+ }
870
+ /** @returns All item sets. */
871
+ async listSets() {
872
+ return this.client.request({
873
+ path: "/item/sets"
874
+ });
875
+ }
876
+ };
877
+ var GuildBannerLayerSchema = zod.z.object({
878
+ color: zod.z.string().optional(),
879
+ colour: zod.z.string().optional(),
880
+ pattern: zod.z.string()
881
+ }).passthrough();
882
+ var GuildBannerSchema2 = zod.z.object({
883
+ base: zod.z.string(),
884
+ tier: zod.z.number(),
885
+ structure: zod.z.string(),
886
+ layers: zod.z.array(GuildBannerLayerSchema)
887
+ }).passthrough();
888
+ var LeaderboardEntrySchema = zod.z.object({
889
+ metaScore: zod.z.number().optional(),
890
+ name: zod.z.string(),
891
+ uuid: zod.z.uuid().optional(),
892
+ prefix: zod.z.string().optional(),
893
+ score: zod.z.number().optional(),
894
+ metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
895
+ banner: GuildBannerSchema2.optional(),
896
+ previousRanking: zod.z.number().optional(),
897
+ level: zod.z.number().optional(),
898
+ xp: zod.z.number().optional(),
899
+ territories: zod.z.number().optional(),
900
+ wars: zod.z.number().optional(),
901
+ created: zod.z.string().optional(),
902
+ characterUuid: zod.z.uuid().optional(),
903
+ characterType: zod.z.string().optional(),
904
+ characterData: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
905
+ rank: zod.z.string().optional(),
906
+ supportRank: zod.z.string().nullable().optional(),
907
+ shortenedRank: zod.z.string().nullable().optional(),
908
+ legacyRankColour: zod.z.object({
909
+ main: zod.z.string(),
910
+ sub: zod.z.string()
911
+ }).optional(),
912
+ rankBadge: zod.z.string().optional(),
913
+ restricted: zod.z.boolean().optional()
914
+ }).passthrough();
915
+ var GetLeaderboardOptionsSchema = zod.z.object({
916
+ resultLimit: zod.z.number().optional()
917
+ });
918
+ var GetLeaderboardResultSchema = zod.z.record(zod.z.string(), LeaderboardEntrySchema);
919
+ var ListLeaderboardTypesResultSchema = zod.z.array(zod.z.string());
920
+
921
+ // src/modules/leaderboards.ts
922
+ var LeaderboardsModule = class {
923
+ constructor(client) {
924
+ this.client = client;
925
+ }
926
+ client;
927
+ /** @returns Available leaderboard type identifiers. */
928
+ async listTypes() {
929
+ return this.client.request({
930
+ path: "/leaderboards/types"
931
+ });
932
+ }
933
+ /**
934
+ * Fetch entries for a leaderboard type.
935
+ *
936
+ * @param lbType - Leaderboard type slug from {@link LeaderboardsModule.listTypes}.
937
+ * @param options.resultLimit - Maximum number of entries to return.
938
+ * @returns Leaderboard entries keyed by rank position.
939
+ */
940
+ async get(lbType, options = {}) {
941
+ const { resultLimit } = options;
942
+ return this.client.request({
943
+ path: `/leaderboards/${encodeURIComponent(lbType)}`,
944
+ params: resultLimit !== void 0 ? { resultLimit } : void 0
945
+ });
946
+ }
947
+ };
948
+ var GetQuestCountResultSchema = zod.z.object({
949
+ quests: zod.z.number()
950
+ });
951
+ var MapCoordinate3DSchema = zod.z.object({
952
+ x: zod.z.number(),
953
+ y: zod.z.number(),
954
+ z: zod.z.number()
955
+ });
956
+
957
+ // src/schemas/map/map.ts
958
+ var WorldEventRequirementSchema = zod.z.object({
959
+ type: zod.z.string(),
960
+ value: zod.z.union([zod.z.number(), zod.z.string()])
961
+ });
962
+ var LootPoolRewardSchema = zod.z.object({
963
+ name: zod.z.string(),
964
+ type: zod.z.string(),
965
+ amount: zod.z.number(),
966
+ always: zod.z.boolean(),
967
+ tier: zod.z.string().nullable().optional(),
968
+ shiny: zod.z.boolean().optional()
969
+ });
970
+ var MapLootPoolQueryOptionsSchema = zod.z.object({
971
+ level: zod.z.number().optional()
972
+ });
973
+ var MapLootPoolContentSchema = zod.z.object({
974
+ name: zod.z.string(),
975
+ internalName: zod.z.string(),
976
+ type: zod.z.string(),
977
+ lore: zod.z.string().nullable(),
978
+ difficulty: zod.z.string().nullable(),
979
+ level: zod.z.number().nullable(),
980
+ length: zod.z.string().nullable(),
981
+ requirements: zod.z.array(WorldEventRequirementSchema).nullable(),
982
+ location: MapCoordinate3DSchema.nullable(),
983
+ rewards: zod.z.array(LootPoolRewardSchema)
984
+ });
985
+ var LootPoolSchema = zod.z.object({
986
+ name: zod.z.string(),
987
+ internalName: zod.z.string(),
988
+ type: zod.z.string(),
989
+ rewards: zod.z.array(LootPoolRewardSchema)
990
+ });
991
+ var WorldEventLocationSchema = zod.z.object({
992
+ event: zod.z.union([MapCoordinate3DSchema, zod.z.null()]),
993
+ spawn: zod.z.union([MapCoordinate3DSchema, zod.z.null()]),
994
+ reward: zod.z.union([MapCoordinate3DSchema, zod.z.null()]),
995
+ radius: zod.z.number().nullable(),
996
+ spawnRadius: zod.z.number().nullable()
997
+ });
998
+ var WorldEventSchema = zod.z.object({
999
+ name: zod.z.string(),
1000
+ internalName: zod.z.string(),
1001
+ lore: zod.z.string(),
1002
+ difficulty: zod.z.string().nullable(),
1003
+ level: zod.z.number().nullable(),
1004
+ length: zod.z.string().nullable(),
1005
+ rewardPerLevel: zod.z.record(zod.z.string(), zod.z.array(zod.z.string())).nullable(),
1006
+ requirements: zod.z.array(WorldEventRequirementSchema).nullable(),
1007
+ location: zod.z.array(WorldEventLocationSchema),
1008
+ schedule: zod.z.string().nullable()
1009
+ });
1010
+ var PlayerLocationMemberSchema = zod.z.object({
1011
+ uuid: zod.z.uuid(),
1012
+ name: zod.z.string(),
1013
+ nickname: zod.z.string().nullable(),
1014
+ character: zod.z.uuid(),
1015
+ server: zod.z.string().nullable(),
1016
+ x: zod.z.number(),
1017
+ y: zod.z.number(),
1018
+ z: zod.z.number()
1019
+ });
1020
+ var PlayerLocationSchema = zod.z.object({
1021
+ uuid: zod.z.uuid(),
1022
+ name: zod.z.string(),
1023
+ nickname: zod.z.string().nullable(),
1024
+ character: zod.z.uuid(),
1025
+ server: zod.z.string().nullable(),
1026
+ x: zod.z.number(),
1027
+ y: zod.z.number(),
1028
+ z: zod.z.number(),
1029
+ friends: zod.z.array(PlayerLocationMemberSchema),
1030
+ party: zod.z.array(PlayerLocationMemberSchema),
1031
+ guild: zod.z.array(PlayerLocationMemberSchema)
1032
+ });
1033
+ var GatheringNodeSchema = zod.z.object({
1034
+ x: zod.z.number(),
1035
+ y: zod.z.number(),
1036
+ z: zod.z.number(),
1037
+ angle: zod.z.number(),
1038
+ type: zod.z.enum(["NODE", "WALL", "CORNER"]),
1039
+ resource: zod.z.string(),
1040
+ level: zod.z.number()
1041
+ });
1042
+ var MapMarkerSchema = zod.z.object({
1043
+ name: zod.z.string(),
1044
+ icon: zod.z.string(),
1045
+ x: zod.z.string(),
1046
+ y: zod.z.string(),
1047
+ z: zod.z.string()
1048
+ });
1049
+
1050
+ // src/schemas/map/list-gathering-nodes.ts
1051
+ var ListGatheringNodesResultSchema = zod.z.array(GatheringNodeSchema);
1052
+ var ListMapMarkersResultSchema = zod.z.array(MapMarkerSchema);
1053
+ var ListMapCampsOptionsSchema = MapLootPoolQueryOptionsSchema;
1054
+ var ListMapCampsResultSchema = zod.z.array(MapLootPoolContentSchema);
1055
+ var ListMapLootPoolsOptionsSchema = MapLootPoolQueryOptionsSchema;
1056
+ var ListMapLootPoolsResultSchema = zod.z.array(LootPoolSchema);
1057
+ var ListMapRaidsOptionsSchema = MapLootPoolQueryOptionsSchema;
1058
+ var ListMapRaidsResultSchema = zod.z.array(MapLootPoolContentSchema);
1059
+ var ListPlayerLocationsResultSchema = zod.z.array(PlayerLocationSchema);
1060
+ var ListWorldEventsResultSchema = zod.z.array(WorldEventSchema);
1061
+
1062
+ // src/modules/map.ts
1063
+ var MapModule = class {
1064
+ constructor(client) {
1065
+ this.client = client;
1066
+ }
1067
+ client;
1068
+ /** @returns Live player locations on the world map. */
1069
+ async listPlayerLocations() {
1070
+ return this.client.request({
1071
+ path: "/map/locations/player"
1072
+ });
1073
+ }
1074
+ /** @returns Map markers such as NPCs, dungeons, and points of interest. */
1075
+ async listMarkers() {
1076
+ return this.client.request({
1077
+ path: "/map/locations/markers"
1078
+ });
1079
+ }
1080
+ /** @returns Currently active world events. */
1081
+ async listWorldEvents() {
1082
+ return this.client.request({
1083
+ path: "/map/world-events"
1084
+ });
1085
+ }
1086
+ /**
1087
+ * List camps.
1088
+ *
1089
+ * @param options.level - Filter to camps at a specific combat level.
1090
+ * @returns Camp definitions and loot pool contents.
1091
+ */
1092
+ async listCamps(options = {}) {
1093
+ const { level } = options;
1094
+ return this.client.request({
1095
+ path: "/map/camps",
1096
+ params: level !== void 0 ? { level } : void 0
1097
+ });
1098
+ }
1099
+ /**
1100
+ * List raids.
1101
+ *
1102
+ * @param options.level - Filter to raids at a specific combat level.
1103
+ * @returns Raid definitions and loot pool contents.
1104
+ */
1105
+ async listRaids(options = {}) {
1106
+ const { level } = options;
1107
+ return this.client.request({
1108
+ path: "/map/raids",
1109
+ params: level !== void 0 ? { level } : void 0
1110
+ });
1111
+ }
1112
+ /**
1113
+ * List loot pools.
1114
+ *
1115
+ * @param options.level - Filter to loot pools at a specific combat level.
1116
+ * @returns Loot pool definitions and contents.
1117
+ */
1118
+ async listLootPools(options = {}) {
1119
+ const { level } = options;
1120
+ return this.client.request({
1121
+ path: "/map/loot-pools",
1122
+ params: level !== void 0 ? { level } : void 0
1123
+ });
1124
+ }
1125
+ /** @returns Gathering node locations across the map. */
1126
+ async listGatheringNodes() {
1127
+ return this.client.request({
1128
+ path: "/map/gathering-nodes"
1129
+ });
1130
+ }
1131
+ /** @returns Quest completion counts across the map. */
1132
+ async getQuestCount() {
1133
+ return this.client.request({
1134
+ path: "/map/quests"
1135
+ });
1136
+ }
1137
+ };
1138
+ var PublisherArticleTypeSchema = zod.z.enum(["blog", "event", "giveaway", "article", "poll"]);
1139
+ var PublisherPollRequirementSchema = zod.z.object({
1140
+ type: zod.z.string(),
1141
+ subType: zod.z.string().nullable(),
1142
+ value: zod.z.number()
1143
+ });
1144
+ var PublisherPollQuestionSchema = zod.z.object({
1145
+ answers: zod.z.record(zod.z.string(), zod.z.string()),
1146
+ override: zod.z.boolean(),
1147
+ question: zod.z.string(),
1148
+ requirements: zod.z.array(PublisherPollRequirementSchema)
1149
+ });
1150
+ var PublisherArticleContentBlockSchema = zod.z.object({
1151
+ id: zod.z.string(),
1152
+ type: zod.z.string(),
1153
+ focus: zod.z.boolean(),
1154
+ content: zod.z.union([zod.z.string(), PublisherPollQuestionSchema]),
1155
+ discord: zod.z.boolean(),
1156
+ website: zod.z.boolean()
1157
+ });
1158
+ var PublisherArticleSchema = zod.z.object({
1159
+ id: zod.z.number(),
1160
+ type: PublisherArticleTypeSchema,
1161
+ created_by: zod.z.string(),
1162
+ discord_messages: zod.z.record(zod.z.string(), zod.z.string()),
1163
+ discord_recap: zod.z.boolean(),
1164
+ allow_discord: zod.z.boolean(),
1165
+ destination: zod.z.string(),
1166
+ published: zod.z.boolean(),
1167
+ pinned: zod.z.boolean(),
1168
+ visible: zod.z.boolean(),
1169
+ content: zod.z.array(PublisherArticleContentBlockSchema),
1170
+ start_date: zod.z.string(),
1171
+ end_date: zod.z.string().nullable(),
1172
+ recap: zod.z.string(),
1173
+ title: zod.z.string(),
1174
+ banner: zod.z.string(),
1175
+ banner_zoom: zod.z.boolean(),
1176
+ likes: zod.z.number(),
1177
+ published_at: zod.z.string(),
1178
+ require_discord: zod.z.boolean(),
1179
+ require_clan: zod.z.boolean(),
1180
+ poll_settings: zod.z.array(PublisherPollRequirementSchema).optional(),
1181
+ poll_public: zod.z.boolean().optional(),
1182
+ votes: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional()
1183
+ }).passthrough();
1184
+ var PublisherArticleSummarySchema = zod.z.object({
1185
+ pk: zod.z.number(),
1186
+ title: zod.z.string(),
1187
+ type: PublisherArticleTypeSchema,
1188
+ banner: zod.z.string(),
1189
+ banner_zoom: zod.z.boolean(),
1190
+ recap: zod.z.string(),
1191
+ visible: zod.z.boolean(),
1192
+ start_date: zod.z.string(),
1193
+ end_date: zod.z.string().nullable(),
1194
+ pinned: zod.z.boolean(),
1195
+ has_content: zod.z.boolean(),
1196
+ published_at: zod.z.string()
1197
+ });
1198
+ var FetchPublisherArticleResultSchema = PublisherArticleSchema;
1199
+ var LatestNewsEntrySchema = zod.z.object({
1200
+ title: zod.z.string(),
1201
+ date: zod.z.string(),
1202
+ forumThread: zod.z.string(),
1203
+ author: zod.z.string(),
1204
+ content: zod.z.string(),
1205
+ comments: zod.z.string()
1206
+ });
1207
+ var ListLatestNewsResultSchema = zod.z.array(LatestNewsEntrySchema);
1208
+ var ListPublisherArticlesOptionsSchema = zod.z.object({
1209
+ page: zod.z.number().optional()
1210
+ });
1211
+ var ListPublisherArticlesResultSchema = zod.z.object({
1212
+ controller: PaginationControllerSchema,
1213
+ results: zod.z.record(zod.z.string(), PublisherArticleSummarySchema)
1214
+ });
1215
+ var ListPublisherVideosResultSchema = zod.z.record(zod.z.string(), zod.z.string());
1216
+
1217
+ // src/modules/news.ts
1218
+ var NewsModule = class {
1219
+ constructor(client) {
1220
+ this.client = client;
1221
+ }
1222
+ client;
1223
+ /**
1224
+ * Fetch a single publisher article.
1225
+ *
1226
+ * @param articleType - Article category: `blog`, `event`, `giveaway`, `article`, or `poll`.
1227
+ * @param pk - Article primary key (numeric ID or slug).
1228
+ * @returns Full article content and metadata.
1229
+ */
1230
+ async fetchArticle(articleType, pk) {
1231
+ return this.client.request({
1232
+ path: `/publisher/articles/fetch/${encodeURIComponent(articleType)}/${encodeURIComponent(String(pk))}`
1233
+ });
1234
+ }
1235
+ /**
1236
+ * List publisher articles of a given type.
1237
+ *
1238
+ * @param articleType - Article category: `blog`, `event`, `giveaway`, `article`, or `poll`.
1239
+ * @param options.page - Page number for paginated results.
1240
+ * @returns Paginated article summaries.
1241
+ */
1242
+ async listArticles(articleType, options = {}) {
1243
+ const { page } = options;
1244
+ return this.client.request({
1245
+ path: `/publisher/articles/list/${encodeURIComponent(articleType)}`,
1246
+ params: page !== void 0 ? { page } : void 0
1247
+ });
1248
+ }
1249
+ /** @returns Publisher video listings. */
1250
+ async listVideos() {
1251
+ return this.client.request({
1252
+ path: "/publisher/videos/list"
1253
+ });
1254
+ }
1255
+ /** @returns Latest news feed entries. */
1256
+ async listLatestNews() {
1257
+ return this.client.request({
1258
+ path: "/latest-news"
1259
+ });
1260
+ }
1261
+ };
1262
+ var ExchangeOAuthTokenOptionsSchema = zod.z.object({
1263
+ code: zod.z.string(),
1264
+ redirectUri: zod.z.string(),
1265
+ clientId: zod.z.string(),
1266
+ clientSecret: zod.z.string().optional(),
1267
+ codeVerifier: zod.z.string().optional()
1268
+ });
1269
+ var ExchangeOAuthTokenResultSchema = zod.z.object({
1270
+ access_token: zod.z.string(),
1271
+ token_type: zod.z.literal("bearer"),
1272
+ scope: zod.z.string()
1273
+ });
1274
+ function toOAuthTokenFormBody(options) {
1275
+ const body = new URLSearchParams();
1276
+ body.set("grant_type", "authorization_code");
1277
+ body.set("code", options.code);
1278
+ body.set("redirect_uri", options.redirectUri);
1279
+ body.set("client_id", options.clientId);
1280
+ if (options.clientSecret) {
1281
+ body.set("client_secret", options.clientSecret);
1282
+ }
1283
+ if (options.codeVerifier) {
1284
+ body.set("code_verifier", options.codeVerifier);
1285
+ }
1286
+ return body;
1287
+ }
1288
+ var LegacyRankColourSchema = zod.z.object({
1289
+ main: zod.z.string(),
1290
+ sub: zod.z.string()
1291
+ });
1292
+ var PlayerIdentitySchema = zod.z.object({
1293
+ username: zod.z.string(),
1294
+ online: zod.z.boolean(),
1295
+ nickname: zod.z.string().nullable(),
1296
+ rank: zod.z.string(),
1297
+ supportRank: zod.z.string().nullable(),
1298
+ shortenedRank: zod.z.string().nullable(),
1299
+ legacyRankColour: LegacyRankColourSchema,
1300
+ rankBadge: zod.z.string()
1301
+ });
1302
+ var WhoAmIResultSchema = zod.z.record(zod.z.uuid(), PlayerIdentitySchema);
1303
+
1304
+ // src/schemas/oauth/get-oauth-identity.ts
1305
+ var OAuthApplicationSchema = zod.z.object({
1306
+ client_id: zod.z.string(),
1307
+ scopes: zod.z.array(zod.z.string())
1308
+ });
1309
+ var OAuthProfileSchema = zod.z.object({
1310
+ username: zod.z.string(),
1311
+ primary: zod.z.boolean(),
1312
+ rank: zod.z.string(),
1313
+ supportRank: zod.z.string().nullable(),
1314
+ shortenedRank: zod.z.string().nullable(),
1315
+ legacyRankColour: LegacyRankColourSchema,
1316
+ rankBadge: zod.z.string(),
1317
+ accessRules: zod.z.record(zod.z.string(), zod.z.string())
1318
+ });
1319
+ var GetOAuthIdentityResultSchema = zod.z.object({
1320
+ application: OAuthApplicationSchema,
1321
+ profiles: zod.z.record(zod.z.uuid(), OAuthProfileSchema)
1322
+ });
1323
+
1324
+ // src/modules/oauth.ts
1325
+ var OAuthModule = class {
1326
+ constructor(client) {
1327
+ this.client = client;
1328
+ }
1329
+ client;
1330
+ /**
1331
+ * Fetch the authenticated OAuth user's identity.
1332
+ *
1333
+ * Requires `{ type: "oauth", accessToken }` credentials on the client.
1334
+ *
1335
+ * @returns OAuth user profile and linked Wynncraft account.
1336
+ */
1337
+ async me() {
1338
+ return this.client.request({
1339
+ path: "/oauth/me"
1340
+ });
1341
+ }
1342
+ /**
1343
+ * Exchange an authorization code for access tokens.
1344
+ *
1345
+ * @param options.code - Authorization code from the OAuth redirect.
1346
+ * @param options.redirectUri - Redirect URI registered with the OAuth app.
1347
+ * @param options.clientId - OAuth application client ID.
1348
+ * @param options.clientSecret - OAuth application client secret (confidential clients).
1349
+ * @param options.codeVerifier - PKCE code verifier, if the flow used PKCE.
1350
+ * @returns Access token and granted scopes.
1351
+ */
1352
+ async exchangeToken(options) {
1353
+ return this.client.request({
1354
+ method: "POST",
1355
+ path: "/oauth/token",
1356
+ data: toOAuthTokenFormBody(options),
1357
+ headers: {
1358
+ "Content-Type": "application/x-www-form-urlencoded"
1359
+ }
1360
+ });
1361
+ }
1362
+ };
1363
+ var LightCharacterMetaSchema = zod.z.object({
1364
+ died: zod.z.boolean()
1365
+ });
1366
+ var LightCharacterSchema = zod.z.object({
1367
+ type: zod.z.string(),
1368
+ reskin: zod.z.string().nullable(),
1369
+ nickname: zod.z.string().nullable(),
1370
+ level: zod.z.number(),
1371
+ xp: zod.z.number(),
1372
+ xpPercent: zod.z.number(),
1373
+ totalLevel: zod.z.number(),
1374
+ gamemode: zod.z.array(zod.z.string()),
1375
+ meta: LightCharacterMetaSchema
1376
+ });
1377
+ var ListPlayerCharactersResultSchema = zod.z.record(zod.z.uuid(), LightCharacterSchema);
1378
+ var GetCharacterAbilitiesResultSchema = AbilityMapPagesSchema;
1379
+ var GetPlayerOptionsSchema = zod.z.object({
1380
+ fullResult: zod.z.boolean().optional()
1381
+ });
1382
+ var GuildReferenceSchema = zod.z.object({
1383
+ uuid: zod.z.uuid(),
1384
+ name: zod.z.string(),
1385
+ prefix: zod.z.string(),
1386
+ rank: zod.z.string().nullable().optional(),
1387
+ rankStars: zod.z.string().nullable().optional()
1388
+ });
1389
+ var RankMapSchema = zod.z.record(zod.z.string(), zod.z.number());
1390
+ var CountListSchema2 = zod.z.object({
1391
+ total: zod.z.number(),
1392
+ list: zod.z.record(zod.z.string(), zod.z.number())
1393
+ });
1394
+ var RaidStatsSchema = zod.z.object({
1395
+ damageTaken: zod.z.number(),
1396
+ damageDealt: zod.z.number(),
1397
+ healthHealed: zod.z.number(),
1398
+ deaths: zod.z.number(),
1399
+ buffsTaken: zod.z.number(),
1400
+ gambitsUsed: zod.z.number()
1401
+ });
1402
+ var PvpStatsSchema2 = zod.z.object({
1403
+ kills: zod.z.number().optional(),
1404
+ deaths: zod.z.number().optional()
1405
+ });
1406
+ var PlayerGlobalDataSchema = zod.z.object({
1407
+ contentCompletion: zod.z.number(),
1408
+ wars: zod.z.number(),
1409
+ totalLevel: zod.z.number(),
1410
+ mobsKilled: zod.z.number(),
1411
+ chestsFound: zod.z.number(),
1412
+ dungeons: CountListSchema2,
1413
+ raids: CountListSchema2,
1414
+ worldEvents: zod.z.number(),
1415
+ lootruns: zod.z.number(),
1416
+ caves: zod.z.number(),
1417
+ completedQuests: zod.z.number(),
1418
+ guildRaids: CountListSchema2.nullable(),
1419
+ raidStats: RaidStatsSchema.nullable(),
1420
+ pvp: PvpStatsSchema2
1421
+ });
1422
+ var ProfessionProgressSchema = zod.z.object({
1423
+ level: zod.z.number(),
1424
+ xpPercent: zod.z.number()
1425
+ });
1426
+ var ProfessionsSchema = zod.z.object({
1427
+ fishing: ProfessionProgressSchema.optional(),
1428
+ woodcutting: ProfessionProgressSchema.optional(),
1429
+ mining: ProfessionProgressSchema.optional(),
1430
+ farming: ProfessionProgressSchema.optional(),
1431
+ scribing: ProfessionProgressSchema.optional(),
1432
+ jeweling: ProfessionProgressSchema.optional(),
1433
+ alchemism: ProfessionProgressSchema.optional(),
1434
+ cooking: ProfessionProgressSchema.optional(),
1435
+ weaponsmithing: ProfessionProgressSchema.optional(),
1436
+ tailoring: ProfessionProgressSchema.optional(),
1437
+ woodworking: ProfessionProgressSchema.optional(),
1438
+ armouring: ProfessionProgressSchema.optional()
1439
+ });
1440
+ var CharacterSchema = zod.z.object({
1441
+ type: zod.z.string(),
1442
+ reskin: zod.z.string().nullable(),
1443
+ nickname: zod.z.string().nullable(),
1444
+ level: zod.z.number(),
1445
+ xp: zod.z.number(),
1446
+ xpPercent: zod.z.number(),
1447
+ totalLevel: zod.z.number(),
1448
+ preEconomy: zod.z.boolean().nullable(),
1449
+ gamemode: zod.z.array(zod.z.string()),
1450
+ contentCompletion: zod.z.number(),
1451
+ wars: zod.z.number(),
1452
+ playtime: zod.z.number(),
1453
+ mobsKilled: zod.z.number(),
1454
+ chestsFound: zod.z.number(),
1455
+ itemsIdentified: zod.z.number(),
1456
+ blocksWalked: zod.z.number(),
1457
+ logins: zod.z.number(),
1458
+ deaths: zod.z.number(),
1459
+ discoveries: zod.z.number(),
1460
+ pvp: PvpStatsSchema2,
1461
+ skillPoints: zod.z.record(zod.z.string(), zod.z.number()).nullable(),
1462
+ professions: ProfessionsSchema,
1463
+ dungeons: CountListSchema2.nullable(),
1464
+ raids: CountListSchema2.nullable(),
1465
+ worldEvents: zod.z.number(),
1466
+ lootruns: zod.z.number(),
1467
+ caves: zod.z.number(),
1468
+ quests: zod.z.array(zod.z.string()),
1469
+ restrictions: zod.z.record(zod.z.string(), zod.z.boolean()),
1470
+ removedStat: zod.z.array(zod.z.string())
1471
+ });
1472
+ var GetPlayerResultSchema = zod.z.object({
1473
+ username: zod.z.string(),
1474
+ online: zod.z.boolean(),
1475
+ server: zod.z.string().nullable(),
1476
+ activeCharacter: zod.z.uuid().nullable(),
1477
+ nickname: zod.z.string().nullable(),
1478
+ uuid: zod.z.uuid(),
1479
+ rank: zod.z.string(),
1480
+ rankBadge: zod.z.string(),
1481
+ legacyRankColour: LegacyRankColourSchema,
1482
+ shortenedRank: zod.z.string().nullable(),
1483
+ supportRank: zod.z.string().nullable(),
1484
+ veteran: zod.z.boolean(),
1485
+ lastJoin: zod.z.string(),
1486
+ guild: GuildReferenceSchema.nullable(),
1487
+ ranking: RankMapSchema,
1488
+ previousRanking: RankMapSchema,
1489
+ firstJoin: zod.z.string(),
1490
+ playtime: zod.z.number(),
1491
+ globalData: PlayerGlobalDataSchema,
1492
+ featuredStats: zod.z.record(zod.z.string(), zod.z.union([zod.z.string(), zod.z.number()])),
1493
+ wallpaper: zod.z.string(),
1494
+ avatar: zod.z.string(),
1495
+ restrictions: zod.z.record(zod.z.string(), zod.z.boolean()),
1496
+ characters: zod.z.record(zod.z.uuid(), CharacterSchema).optional()
1497
+ });
1498
+ var ListOnlinePlayersOptionsSchema = zod.z.object({
1499
+ identifier: zod.z.union([zod.z.string(), zod.z.uuid()]).optional(),
1500
+ server: zod.z.union([zod.z.string(), zod.z.number()]).optional()
1501
+ });
1502
+ var ListOnlinePlayersResultSchema = zod.z.object({
1503
+ total: zod.z.number(),
1504
+ players: zod.z.record(zod.z.string(), zod.z.string())
1505
+ });
1506
+
1507
+ // src/modules/player.ts
1508
+ var PlayerModule = class {
1509
+ constructor(client) {
1510
+ this.client = client;
1511
+ }
1512
+ client;
1513
+ /**
1514
+ * List currently online players.
1515
+ *
1516
+ * @param options.identifier - Filter by username or UUID.
1517
+ * @param options.server - Filter by server name or number.
1518
+ * @returns Online player count and username-to-server map.
1519
+ */
1520
+ async listOnlinePlayers(options = {}) {
1521
+ return this.client.request({
1522
+ path: "/player",
1523
+ params: options
1524
+ });
1525
+ }
1526
+ /**
1527
+ * Fetch the authenticated player's profile.
1528
+ *
1529
+ * Requires credentials on the client.
1530
+ *
1531
+ * @returns UUID-keyed map of {@link PlayerIdentity}. The API returns a
1532
+ * single entry for the authenticated account.
1533
+ *
1534
+ * @example
1535
+ * ```ts
1536
+ * const { data } = await client.player.whoAmI();
1537
+ * const profile = Object.values(data)[0]!;
1538
+ * ```
1539
+ */
1540
+ async whoAmI() {
1541
+ return this.client.request({
1542
+ path: "/player/whoami"
1543
+ });
1544
+ }
1545
+ /**
1546
+ * Fetch a player profile by username.
1547
+ *
1548
+ * @param username - Wynncraft username.
1549
+ * @param options.fullResult - Include extended character data when `true`.
1550
+ * @returns Player profile and character summaries.
1551
+ */
1552
+ async getPlayer(username, options = {}) {
1553
+ return this.client.request({
1554
+ path: `/player/${encodeURIComponent(username)}`,
1555
+ presenceParams: options.fullResult ? ["fullResult"] : void 0
1556
+ });
1557
+ }
1558
+ /**
1559
+ * List characters for a player.
1560
+ *
1561
+ * @param username - Wynncraft username.
1562
+ * @returns Character list keyed by UUID.
1563
+ */
1564
+ async listCharacters(username) {
1565
+ return this.client.request({
1566
+ path: `/player/${encodeURIComponent(username)}/characters`
1567
+ });
1568
+ }
1569
+ /**
1570
+ * Fetch ability assignments for a specific character.
1571
+ *
1572
+ * @param username - Wynncraft username.
1573
+ * @param characterUuid - Character UUID from {@link PlayerModule.listCharacters}.
1574
+ * @returns Ability map keyed by page.
1575
+ */
1576
+ async getCharacterAbilities(username, characterUuid) {
1577
+ return this.client.request({
1578
+ path: `/player/${encodeURIComponent(username)}/characters/${encodeURIComponent(characterUuid)}/abilities`
1579
+ });
1580
+ }
1581
+ };
1582
+ var SearchGuildResultSchema = zod.z.object({
1583
+ name: zod.z.string(),
1584
+ prefix: zod.z.string()
1585
+ });
1586
+ var SearchAreaResultSchema = zod.z.object({
1587
+ start: zod.z.array(zod.z.unknown()),
1588
+ end: zod.z.array(zod.z.unknown())
1589
+ });
1590
+ var GlobalSearchOptionsSchema = zod.z.object({
1591
+ only: zod.z.string().optional()
1592
+ });
1593
+ var GlobalSearchResultSchema = zod.z.object({
1594
+ query: zod.z.string(),
1595
+ players: zod.z.record(zod.z.string(), zod.z.string()).optional(),
1596
+ guilds: zod.z.record(zod.z.string(), SearchGuildResultSchema).optional(),
1597
+ items: ItemListSchema.optional(),
1598
+ guildsPrefix: zod.z.record(zod.z.string(), SearchGuildResultSchema).optional(),
1599
+ territories: zod.z.record(zod.z.string(), SearchAreaResultSchema).optional(),
1600
+ discoveries: zod.z.record(zod.z.string(), SearchAreaResultSchema).optional()
1601
+ });
1602
+
1603
+ // src/modules/search.ts
1604
+ var SearchModule = class {
1605
+ constructor(client) {
1606
+ this.client = client;
1607
+ }
1608
+ client;
1609
+ /**
1610
+ * Search across Wynncraft resources.
1611
+ *
1612
+ * @param query - Free-text search query.
1613
+ * @param options.only - Limit results to a resource type, e.g. `player`, `guild`, or `item`.
1614
+ * @returns Matching players, guilds, items, and related entities.
1615
+ */
1616
+ async search(query, options = {}) {
1617
+ const { only } = options;
1618
+ return this.client.request({
1619
+ path: `/search/${encodeURIComponent(query)}`,
1620
+ params: only !== void 0 ? { only } : void 0
1621
+ });
1622
+ }
1623
+ };
1624
+
1625
+ // src/client.ts
1626
+ var WynnClient = class {
1627
+ /** Player profiles, characters, and online status. */
1628
+ player;
1629
+ /** Guild listings, seasons, and territory data. */
1630
+ guild;
1631
+ /** Item database, search, recipes, and metadata. */
1632
+ item;
1633
+ /** Ability trees, maps, and aspects. */
1634
+ ability;
1635
+ /** Playable classes and their metadata. */
1636
+ classes;
1637
+ /** Map markers, raids, camps, and world events. */
1638
+ map;
1639
+ /** Leaderboard types and rankings. */
1640
+ leaderboards;
1641
+ /** Publisher articles, videos, and latest news. */
1642
+ news;
1643
+ /** Global search across players, guilds, and items. */
1644
+ search;
1645
+ /** OAuth identity and token exchange. */
1646
+ oauth;
1647
+ http;
1648
+ auth;
1649
+ /**
1650
+ * @param options - Client configuration. All fields are optional.
1651
+ * @param options.baseUrl - API base URL. Defaults to {@link API_BASE_URL}.
1652
+ * @param options.auth - Credentials for authenticated endpoints.
1653
+ * @param options.http - Custom Axios instance, e.g. for mocking in tests.
1654
+ */
1655
+ constructor(options = {}) {
1656
+ this.auth = options.auth;
1657
+ this.http = options.http ?? axios__default.default.create({
1658
+ baseURL: options.baseUrl ?? API_BASE_URL,
1659
+ headers: {
1660
+ "Content-Type": "application/json",
1661
+ ...authHeaders(this.auth)
1662
+ }
1663
+ });
1664
+ this.http.interceptors.response.use(
1665
+ (response) => response,
1666
+ (error) => Promise.reject(toWynnApiError(error) ?? error)
1667
+ );
1668
+ this.player = new PlayerModule(this);
1669
+ this.guild = new GuildModule(this);
1670
+ this.item = new ItemModule(this);
1671
+ this.ability = new AbilityModule(this);
1672
+ this.classes = new ClassesModule(this);
1673
+ this.map = new MapModule(this);
1674
+ this.leaderboards = new LeaderboardsModule(this);
1675
+ this.news = new NewsModule(this);
1676
+ this.search = new SearchModule(this);
1677
+ this.oauth = new OAuthModule(this);
1678
+ }
1679
+ /**
1680
+ * Low-level request helper. Prefer module methods when available.
1681
+ *
1682
+ * @param config.path - API route path, e.g. `/player/foo`.
1683
+ * @param config.method - HTTP method. Defaults to `GET`.
1684
+ * @param config.params - Standard query parameters.
1685
+ * @param config.presenceParams - Wynncraft presence flags without values, e.g. `fullResult`.
1686
+ * @param config.data - Request body for `POST`/`PUT` requests.
1687
+ * @param config.headers - Additional request headers.
1688
+ * @returns Parsed response body and rate-limit metadata.
1689
+ */
1690
+ async request(config) {
1691
+ const response = await this.http.request(toAxiosRequestConfig(config));
1692
+ return {
1693
+ data: response.data,
1694
+ rateLimit: parseRateLimit(response.headers)
1695
+ };
1696
+ }
1697
+ /** Return the credentials passed at construction, if any. */
1698
+ getAuth() {
1699
+ return this.auth;
1700
+ }
1701
+ };
1702
+
1703
+ exports.API_BASE_URL = API_BASE_URL;
1704
+ exports.AbilityIconSchema = AbilityIconSchema;
1705
+ exports.AbilityMapNodeSchema = AbilityMapNodeSchema;
1706
+ exports.AbilityMapPagesSchema = AbilityMapPagesSchema;
1707
+ exports.CDN_BASE_URL = CDN_BASE_URL;
1708
+ exports.ClassNameSchema = ClassNameSchema;
1709
+ exports.ClassTreeSchema = ClassTreeSchema;
1710
+ exports.ExchangeOAuthTokenOptionsSchema = ExchangeOAuthTokenOptionsSchema;
1711
+ exports.ExchangeOAuthTokenResultSchema = ExchangeOAuthTokenResultSchema;
1712
+ exports.FetchPublisherArticleResultSchema = FetchPublisherArticleResultSchema;
1713
+ exports.GatheringNodeSchema = GatheringNodeSchema;
1714
+ exports.GetAbilityMapResultSchema = GetAbilityMapResultSchema;
1715
+ exports.GetAbilityTreeResultSchema = GetAbilityTreeResultSchema;
1716
+ exports.GetCharacterAbilitiesResultSchema = GetCharacterAbilitiesResultSchema;
1717
+ exports.GetClassResultSchema = GetClassResultSchema;
1718
+ exports.GetGuildOptionsSchema = GetGuildOptionsSchema;
1719
+ exports.GetItemMetadataOptionsSchema = GetItemMetadataOptionsSchema;
1720
+ exports.GetLeaderboardOptionsSchema = GetLeaderboardOptionsSchema;
1721
+ exports.GetLeaderboardResultSchema = GetLeaderboardResultSchema;
1722
+ exports.GetOAuthIdentityResultSchema = GetOAuthIdentityResultSchema;
1723
+ exports.GetPlayerOptionsSchema = GetPlayerOptionsSchema;
1724
+ exports.GetPlayerResultSchema = GetPlayerResultSchema;
1725
+ exports.GetQuestCountResultSchema = GetQuestCountResultSchema;
1726
+ exports.GlobalSearchOptionsSchema = GlobalSearchOptionsSchema;
1727
+ exports.GlobalSearchResultSchema = GlobalSearchResultSchema;
1728
+ exports.GuildResultSchema = GuildResultSchema;
1729
+ exports.IdentificationValueSchema = IdentificationValueSchema;
1730
+ exports.ItemListSchema = ItemListSchema;
1731
+ exports.ItemMetadataSchema = ItemMetadataSchema;
1732
+ exports.ItemSchema = ItemSchema;
1733
+ exports.ItemSearchRequestSchema = ItemSearchRequestSchema;
1734
+ exports.ItemStaticMetadataSchema = ItemStaticMetadataSchema;
1735
+ exports.LeaderboardEntrySchema = LeaderboardEntrySchema;
1736
+ exports.LegacyRankColourSchema = LegacyRankColourSchema;
1737
+ exports.ListAspectsResultSchema = ListAspectsResultSchema;
1738
+ exports.ListClassesResultSchema = ListClassesResultSchema;
1739
+ exports.ListGatheringNodesResultSchema = ListGatheringNodesResultSchema;
1740
+ exports.ListGuildSeasonsResultSchema = ListGuildSeasonsResultSchema;
1741
+ exports.ListGuildTerritoriesResultSchema = ListGuildTerritoriesResultSchema;
1742
+ exports.ListGuildsByNameResultSchema = ListGuildsByNameResultSchema;
1743
+ exports.ListGuildsByUuidResultSchema = ListGuildsByUuidResultSchema;
1744
+ exports.ListGuildsOptionsSchema = ListGuildsOptionsSchema;
1745
+ exports.ListItemSetsResultSchema = ListItemSetsResultSchema;
1746
+ exports.ListItemsOptionsSchema = ListItemsOptionsSchema;
1747
+ exports.ListItemsResultSchema = ListItemsResultSchema;
1748
+ exports.ListLatestNewsResultSchema = ListLatestNewsResultSchema;
1749
+ exports.ListLeaderboardTypesResultSchema = ListLeaderboardTypesResultSchema;
1750
+ exports.ListMapCampsOptionsSchema = ListMapCampsOptionsSchema;
1751
+ exports.ListMapCampsResultSchema = ListMapCampsResultSchema;
1752
+ exports.ListMapLootPoolsOptionsSchema = ListMapLootPoolsOptionsSchema;
1753
+ exports.ListMapLootPoolsResultSchema = ListMapLootPoolsResultSchema;
1754
+ exports.ListMapMarkersResultSchema = ListMapMarkersResultSchema;
1755
+ exports.ListMapRaidsOptionsSchema = ListMapRaidsOptionsSchema;
1756
+ exports.ListMapRaidsResultSchema = ListMapRaidsResultSchema;
1757
+ exports.ListOnlinePlayersOptionsSchema = ListOnlinePlayersOptionsSchema;
1758
+ exports.ListOnlinePlayersResultSchema = ListOnlinePlayersResultSchema;
1759
+ exports.ListPlayerCharactersResultSchema = ListPlayerCharactersResultSchema;
1760
+ exports.ListPlayerLocationsResultSchema = ListPlayerLocationsResultSchema;
1761
+ exports.ListPublisherArticlesOptionsSchema = ListPublisherArticlesOptionsSchema;
1762
+ exports.ListPublisherArticlesResultSchema = ListPublisherArticlesResultSchema;
1763
+ exports.ListPublisherVideosResultSchema = ListPublisherVideosResultSchema;
1764
+ exports.ListRecipesOptionsSchema = ListRecipesOptionsSchema;
1765
+ exports.ListRecipesResultSchema = ListRecipesResultSchema;
1766
+ exports.ListWorldEventsResultSchema = ListWorldEventsResultSchema;
1767
+ exports.LootPoolRewardSchema = LootPoolRewardSchema;
1768
+ exports.LootPoolSchema = LootPoolSchema;
1769
+ exports.MapCoordinate3DSchema = MapCoordinate3DSchema;
1770
+ exports.MapLootPoolContentSchema = MapLootPoolContentSchema;
1771
+ exports.MapLootPoolQueryOptionsSchema = MapLootPoolQueryOptionsSchema;
1772
+ exports.MapMarkerSchema = MapMarkerSchema;
1773
+ exports.MultipleObjectsEntrySchema = MultipleObjectsEntrySchema;
1774
+ exports.MultipleObjectsMapSchema = MultipleObjectsMapSchema;
1775
+ exports.MultipleObjectsReturnedBodySchema = MultipleObjectsReturnedBodySchema;
1776
+ exports.PaginatedItemQueryOptionsSchema = PaginatedItemQueryOptionsSchema;
1777
+ exports.PaginatedItemResponseSchema = PaginatedItemResponseSchema;
1778
+ exports.PaginatedQueryOptionsSchema = PaginatedQueryOptionsSchema;
1779
+ exports.PaginatedRecipeQueryOptionsSchema = PaginatedRecipeQueryOptionsSchema;
1780
+ exports.PaginatedRecipeResponseSchema = PaginatedRecipeResponseSchema;
1781
+ exports.PaginationControllerSchema = PaginationControllerSchema;
1782
+ exports.PlayerIdentitySchema = PlayerIdentitySchema;
1783
+ exports.PlayerLocationMemberSchema = PlayerLocationMemberSchema;
1784
+ exports.PlayerLocationSchema = PlayerLocationSchema;
1785
+ exports.PublisherArticleSchema = PublisherArticleSchema;
1786
+ exports.PublisherArticleSummarySchema = PublisherArticleSummarySchema;
1787
+ exports.PublisherArticleTypeSchema = PublisherArticleTypeSchema;
1788
+ exports.QuickSearchItemsResultSchema = QuickSearchItemsResultSchema;
1789
+ exports.RecipeListSchema = RecipeListSchema;
1790
+ exports.RecipeSchema = RecipeSchema;
1791
+ exports.RecipeSearchRequestSchema = RecipeSearchRequestSchema;
1792
+ exports.SearchItemsOptionsSchema = SearchItemsOptionsSchema;
1793
+ exports.SearchItemsResultSchema = SearchItemsResultSchema;
1794
+ exports.SearchRecipesOptionsSchema = SearchRecipesOptionsSchema;
1795
+ exports.SearchRecipesResultSchema = SearchRecipesResultSchema;
1796
+ exports.WYNNCRAFT_API_VERSION = WYNNCRAFT_API_VERSION;
1797
+ exports.WhoAmIResultSchema = WhoAmIResultSchema;
1798
+ exports.WorldEventRequirementSchema = WorldEventRequirementSchema;
1799
+ exports.WorldEventSchema = WorldEventSchema;
1800
+ exports.WynnClient = WynnClient;
1801
+ exports.assetUrl = assetUrl;
1802
+ exports.toOAuthTokenFormBody = toOAuthTokenFormBody;
1803
+ //# sourceMappingURL=index.cjs.map
1804
+ //# sourceMappingURL=index.cjs.map