warframe-nexus-query 2.2.2 → 2.3.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/index.js CHANGED
@@ -7,6 +7,7 @@ import md from 'node-md-config';
7
7
  import promiseTimeout from './lib/promiseTimeout.js';
8
8
  import Settings from './lib/Settings.js';
9
9
  import Creator from './lib/AttachmentCreator.js';
10
+ import { normalizePriceCheckRanks } from './lib/priceCheckOptions.js';
10
11
  import { MarketFetcherV2 } from './lib/market/v2/index.js';
11
12
 
12
13
  export default class PriceCheckQuerier {
@@ -54,10 +55,11 @@ export default class PriceCheckQuerier {
54
55
  /**
55
56
  * Lookup a list of results for a query
56
57
  * @param {string} query Query to search the nexus-stats database against
57
- * @param {string} platform Platform to query price data for. One of 'pc', 'ps4', 'xb1'
58
+ * @param {string} [platform='pc'] Platform to query price data for. One of 'pc', 'ps4', 'xb1'
59
+ * @param {Object} [options={}] Optional market order filters (rank, ranks, rankLt, etc.)
58
60
  * @returns {Promise<Array<NexusItem>>} a Promise of an array of Item objects
59
61
  */
60
- async priceCheckQuery(query, platform = 'pc') {
62
+ async priceCheckQuery(query, platform = 'pc', options = {}) {
61
63
  this.logger.info(`state:\n\tskipMarket: ${this.skipMarket}\n\tquery: ${query}\n\tplatform: ${platform}`);
62
64
  if (!query) {
63
65
  throw new Error('This funtcion requires a query to be provided');
@@ -65,19 +67,28 @@ export default class PriceCheckQuerier {
65
67
  // eslint-disable-next-line no-param-reassign
66
68
  platform = this.settings.lookupAlias(platform.toLowerCase());
67
69
 
68
- let successfulQuery;
70
+ const ranks = normalizePriceCheckRanks(options);
71
+ const { ranks: _ignoredRanks, ...baseOptions } = options;
69
72
  let attachments = [];
70
73
 
71
74
  /* istanbul ignore else */
72
75
  if (this.marketFetcher && !this.skipMarket) {
73
76
  this.logger.info(`querying market for ${query} on ${platform}`);
74
77
  try {
75
- const marketPromise = this.marketFetcher.queryMarket(query, {
76
- successfulQuery,
77
- platform: this.settings.lookupAlias(platform, true),
78
- });
79
- const marketResults = await promiseTimeout(this.settings.timeouts.market, marketPromise);
80
- attachments = [...attachments, ...marketResults];
78
+ const marketPlatform = this.settings.lookupAlias(platform, true);
79
+ const rankResults = await Promise.all(
80
+ ranks.map(async (rank) => {
81
+ const rankOptions = {
82
+ ...baseOptions,
83
+ platform: marketPlatform,
84
+ };
85
+ if (rank !== undefined) rankOptions.rank = rank;
86
+
87
+ const marketPromise = this.marketFetcher.queryMarket(query, rankOptions);
88
+ return promiseTimeout(this.settings.timeouts.market, marketPromise);
89
+ })
90
+ );
91
+ attachments = rankResults.flat();
81
92
  } catch (e) {
82
93
  this.logger.error(`Couldn't process ${query} on warframe.market... time out.`);
83
94
  }
@@ -91,12 +102,13 @@ export default class PriceCheckQuerier {
91
102
  /**
92
103
  * Lookup a list of results for a query
93
104
  * @param {string} query Query to search the nexus-stats database against
94
- * @param {Object[]} priorResults results provided from a prior search
95
- * @param {string} platform Platform to query price data for. One of 'pc', 'ps4', 'xb1'
105
+ * @param {Object[]} [priorResults] results provided from a prior search
106
+ * @param {string} [platform='pc'] Platform to query price data for. One of 'pc', 'ps4', 'xb1'
107
+ * @param {Object} [options={}] Optional market order filters (rank, ranks, rankLt, etc.)
96
108
  * @returns {Promise<string>} a Promise of a string containing the results of the query
97
109
  */
98
- async priceCheckQueryString(query, priorResults, platform = 'pc') {
99
- const components = priorResults || (await this.priceCheckQuery(query, platform));
110
+ async priceCheckQueryString(query, priorResults, platform = 'pc', options = {}) {
111
+ const components = priorResults || (await this.priceCheckQuery(query, platform, options));
100
112
  const tokens = [`[${platform.toUpperCase()}] ${query}`];
101
113
  components.slice(0, 4).forEach((component) => {
102
114
  tokens.push(`${md.lineEnd}${component.toString()}`);
@@ -109,12 +121,13 @@ export default class PriceCheckQuerier {
109
121
  /**
110
122
  * Lookup a list of results for a query
111
123
  * @param {string} query Query to search the nexus-stats database against
112
- * @param {Object[]} priorResults results provided from a prior search
113
- * @param {string} platform Platform to query price data for. One of 'pc', 'ps4', 'xb1'
124
+ * @param {Object[]} [priorResults] results provided from a prior search
125
+ * @param {string} [platform='pc'] Platform to query price data for. One of 'pc', 'ps4', 'xb1'
126
+ * @param {Object} [options={}] Optional market order filters (rank, ranks, rankLt, etc.)
114
127
  * @returns {Promise<Array<Object>>} a Promise of an array of attachment objects
115
128
  */
116
- async priceCheckQueryAttachment(query, priorResults, platform = 'pc') {
117
- const components = priorResults || (await this.priceCheckQuery(query, platform));
129
+ async priceCheckQueryAttachment(query, priorResults, platform = 'pc', options = {}) {
130
+ const components = priorResults || (await this.priceCheckQuery(query, platform, options));
118
131
  const realPlatform = this.settings.lookupAlias(platform);
119
132
 
120
133
  const attachment = this.creator.attachmentFromComponents(components, query, realPlatform);
@@ -3,6 +3,8 @@
3
3
  * Main entry point for interacting with the Warframe Market API v2
4
4
  */
5
5
 
6
+ import { extractOrderFilters, labelSummaryForFilters } from '../../priceCheckOptions.js';
7
+
6
8
  import HttpClient from './utils/http.js';
7
9
  import VersionedCache from './utils/cache.js';
8
10
  import Item from './models/Item.js';
@@ -261,12 +263,14 @@ export default class MarketFetcherV2 {
261
263
  * @returns {Promise<Summary[]>}
262
264
  */
263
265
  async queryMarket(query, options = {}) {
264
- const { platform, successfulQuery } = options;
266
+ const { platform, successfulQuery, ranks: _ranks, ...rest } = options;
265
267
 
266
268
  if (!platform) {
267
269
  throw new Error('Platform is required');
268
270
  }
269
271
 
272
+ const orderFilters = extractOrderFilters(rest);
273
+
270
274
  // Search for item
271
275
  const items = await this.getItems();
272
276
  const normalizedQuery = query.toLowerCase().trim();
@@ -289,7 +293,7 @@ export default class MarketFetcherV2 {
289
293
  const item = await this.getItemBySlug(matchedSlug);
290
294
 
291
295
  // Get top orders for the item
292
- const topOrders = await this.getTopOrders(item.slug, { platform });
296
+ const topOrders = await this.getTopOrders(item.slug, { platform, ...orderFilters });
293
297
 
294
298
  // Calculate statistics
295
299
  const sellStats = this.calculateStatistics(topOrders.sell, {
@@ -307,10 +311,13 @@ export default class MarketFetcherV2 {
307
311
  }
308
312
 
309
313
  // Create Summary object for v1 compatibility
310
- const summary = new Summary(item, topOrders, {
311
- sell: sellStats,
312
- buy: buyStats,
313
- });
314
+ const summary = labelSummaryForFilters(
315
+ new Summary(item, topOrders, {
316
+ sell: sellStats,
317
+ buy: buyStats,
318
+ }),
319
+ orderFilters
320
+ );
314
321
 
315
322
  // Return array of summaries (v1 compatibility)
316
323
  return [summary];
@@ -320,10 +327,11 @@ export default class MarketFetcherV2 {
320
327
  * Price check query (v1 compatibility method)
321
328
  * @param {string} query - Search query
322
329
  * @param {string} platform - Platform
330
+ * @param {Object} [options={}] - Optional order filters (rank, ranks, rankLt, etc.)
323
331
  * @returns {Promise<Object>}
324
332
  */
325
- async priceCheckQuery(query, platform) {
326
- return this.queryMarket(query, { platform });
333
+ async priceCheckQuery(query, platform, options = {}) {
334
+ return this.queryMarket(query, { platform, ...options });
327
335
  }
328
336
 
329
337
  // ==========================================================================
@@ -0,0 +1,71 @@
1
+ export const ORDER_FILTER_KEYS = [
2
+ 'rank',
3
+ 'rankLt',
4
+ 'charges',
5
+ 'chargesLt',
6
+ 'amberStars',
7
+ 'amberStarsLt',
8
+ 'cyanStars',
9
+ 'cyanStarsLt',
10
+ 'subtype',
11
+ ];
12
+
13
+ /**
14
+ * @param {unknown} value - Rank value from query options
15
+ * @returns {number|undefined}
16
+ */
17
+ export function parseRankValue(value) {
18
+ if (value === undefined || value === '') return undefined;
19
+ const rank = Number(value);
20
+ if (!Number.isInteger(rank) || rank < 0) return undefined;
21
+ return rank;
22
+ }
23
+
24
+ /**
25
+ * Resolve which mod ranks to price-check. `[undefined]` means no rank filter.
26
+ * @param {Record<string, unknown>} [options={}] - Price check options
27
+ * @returns {Array<number|undefined>}
28
+ */
29
+ export function normalizePriceCheckRanks(options = {}) {
30
+ if (Array.isArray(options.ranks) && options.ranks.length) {
31
+ const parsed = options.ranks.map(parseRankValue).filter((rank) => rank !== undefined);
32
+ if (parsed.length) {
33
+ return [...new Set(parsed)].sort((a, b) => a - b);
34
+ }
35
+ }
36
+
37
+ const single = parseRankValue(options.rank);
38
+ if (single !== undefined) return [single];
39
+
40
+ return [undefined];
41
+ }
42
+
43
+ /**
44
+ * @param {Record<string, unknown>} [options={}] - Price check options
45
+ * @returns {Record<string, unknown>}
46
+ */
47
+ export function extractOrderFilters(options = {}) {
48
+ /** @type {Record<string, unknown>} */
49
+ const filters = {};
50
+
51
+ ORDER_FILTER_KEYS.forEach((key) => {
52
+ if (options[key] !== undefined) filters[key] = options[key];
53
+ });
54
+
55
+ return filters;
56
+ }
57
+
58
+ /**
59
+ * @param {{ name: string }} summary - Market summary to label
60
+ * @param {Record<string, unknown>} filters - Active order filters
61
+ * @returns {{ name: string }}
62
+ */
63
+ export function labelSummaryForFilters(summary, filters) {
64
+ if (filters.rank !== undefined) {
65
+ summary.name = `${summary.name} (R${filters.rank})`;
66
+ } else if (filters.rankLt !== undefined) {
67
+ summary.name = `${summary.name} (<R${filters.rankLt})`;
68
+ }
69
+
70
+ return summary;
71
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warframe-nexus-query",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "description": "Query prices form nexus-stats.com and warframe.market.",
5
5
  "keywords": [
6
6
  "warframe",
@@ -20,13 +20,15 @@
20
20
  "author": "tobitenno",
21
21
  "type": "module",
22
22
  "main": "index.js",
23
+ "types": "./types/index.d.ts",
23
24
  "directories": {
24
25
  "test": "test"
25
26
  },
26
27
  "files": [
27
28
  "lib",
28
29
  "index.js",
29
- "basedir.js"
30
+ "basedir.js",
31
+ "types"
30
32
  ],
31
33
  "scripts": {
32
34
  "build:docs": "jsdoc -c jsdoc-config.json -d docs",
@@ -43,15 +45,15 @@
43
45
  "numeral": "^2.0.6"
44
46
  },
45
47
  "devDependencies": {
46
- "@commitlint/cli": "^20.0.0",
47
- "@commitlint/config-conventional": "^20.0.0",
48
+ "@commitlint/cli": "^21.0.1",
49
+ "@commitlint/config-conventional": "^21.0.1",
48
50
  "@types/json-query": "^2.2.0",
49
51
  "@wfcd/eslint-config": "^1.6.1",
50
- "c8": "^10.1.2",
52
+ "c8": "^11.0.0",
51
53
  "chai": "^6.0.1",
52
54
  "husky": "^9.0.11",
53
55
  "install-peerdeps": "^3.0.3",
54
- "lint-staged": "^16.0.0",
56
+ "lint-staged": "^17.0.5",
55
57
  "mocha": "^11.0.1",
56
58
  "prettier": "^3.2.5"
57
59
  },
@@ -0,0 +1,522 @@
1
+ /**
2
+ * TypeScript type definitions for warframe-nexus-query
3
+ * Library for querying Warframe item prices from warframe.market
4
+ */
5
+
6
+ export type Platform = 'pc' | 'ps4' | 'xbox' | 'switch' | 'mobile';
7
+ export type PlatformAlias =
8
+ | 'pc'
9
+ | 'ps4'
10
+ | 'playstation'
11
+ | 'xb1'
12
+ | 'xbone'
13
+ | 'xbox'
14
+ | 'switch'
15
+ | 'swi'
16
+ | 'ns'
17
+ | 'mobile';
18
+ export type Language = 'en' | 'es' | 'fr' | 'de' | 'it' | 'pl' | 'pt' | 'ru' | 'ko' | 'zh-hans' | 'zh-hant' | 'uk';
19
+ export type OrderType = 'buy' | 'sell';
20
+ export type UserStatus = 'invisible' | 'offline' | 'online' | 'ingame';
21
+ export type ActivityType = 'UNKNOWN' | 'IDLE' | 'ON_MISSION' | 'IN_DOJO' | 'IN_ORBITER' | 'IN_RELAY';
22
+ export type Rarity = 'common' | 'uncommon' | 'rare' | 'legendary';
23
+
24
+ export interface Logger {
25
+ debug(message: string, ...args: unknown[]): void;
26
+ info(message: string, ...args: unknown[]): void;
27
+ warn(message: string, ...args: unknown[]): void;
28
+ error(message: string, ...args: unknown[]): void;
29
+ log(message: string, ...args: unknown[]): void;
30
+ }
31
+
32
+ export interface LocalizedData {
33
+ name: string;
34
+ description?: string;
35
+ icon?: string;
36
+ thumb?: string;
37
+ subIcon?: string;
38
+ wikiLink?: string;
39
+ }
40
+
41
+ export interface I18nData {
42
+ [lang: string]: LocalizedData;
43
+ }
44
+
45
+ export interface ItemData {
46
+ id: string;
47
+ slug: string;
48
+ gameRef?: string;
49
+ tags?: string[];
50
+ rarity?: Rarity;
51
+ tradingTax?: number;
52
+ ducats?: number;
53
+ vosfor?: number;
54
+ baseEndo?: number;
55
+ endoMultiplier?: number;
56
+ reqMasteryRank?: number;
57
+ maxRank?: number;
58
+ maxCharges?: number;
59
+ maxAmberStars?: number;
60
+ maxCyanStars?: number;
61
+ setRoot?: boolean;
62
+ setParts?: string[];
63
+ quantityInSet?: number;
64
+ bulkTradable?: boolean;
65
+ subtypes?: string[];
66
+ tradable?: boolean;
67
+ vaulted?: boolean;
68
+ i18n: I18nData;
69
+ }
70
+
71
+ export interface OrderUserData {
72
+ id: string;
73
+ ingameName: string;
74
+ avatar?: string;
75
+ reputation?: number;
76
+ locale?: string;
77
+ platform?: Platform;
78
+ crossplay?: boolean;
79
+ status?: UserStatus;
80
+ activity?: UserActivity;
81
+ lastSeen?: string;
82
+ }
83
+
84
+ export interface UserActivity {
85
+ type: ActivityType;
86
+ details?: string;
87
+ startedAt?: string;
88
+ }
89
+
90
+ export interface OrderData {
91
+ id: string;
92
+ type: OrderType;
93
+ platinum: number;
94
+ quantity: number;
95
+ perTrade?: boolean;
96
+ rank?: number;
97
+ charges?: number;
98
+ subtype?: string;
99
+ amberStars?: number;
100
+ cyanStars?: number;
101
+ visible?: boolean;
102
+ createdAt?: string;
103
+ updatedAt?: string;
104
+ itemId?: string;
105
+ group?: string;
106
+ user?: OrderUserData;
107
+ }
108
+
109
+ export interface PriceRange {
110
+ minimum: number;
111
+ maximum: number;
112
+ median: number;
113
+ }
114
+
115
+ export interface StatisticsData {
116
+ volume: number;
117
+ orderCount: number;
118
+ median: number;
119
+ min: number;
120
+ max: number;
121
+ avg: number;
122
+ q1: number;
123
+ q3: number;
124
+ }
125
+
126
+ export interface SummaryPrices {
127
+ soldCount: number;
128
+ soldPrice: number;
129
+ minimum: number;
130
+ maximum: number;
131
+ average: number;
132
+ volume: number;
133
+ }
134
+
135
+ export interface SummaryData {
136
+ name: string;
137
+ slug: string;
138
+ thumbnail: string;
139
+ partThumb?: string;
140
+ icon?: string;
141
+ tradingTax: number;
142
+ ducats?: number;
143
+ vosfor?: number;
144
+ masteryLevel?: number;
145
+ tradable?: boolean;
146
+ vaulted?: boolean;
147
+ wikiUrl?: string;
148
+ description?: string;
149
+ codex?: string;
150
+ url: string;
151
+ tags?: string[];
152
+ prices: SummaryPrices;
153
+ orders: {
154
+ buy: Order[];
155
+ sell: Order[];
156
+ };
157
+ statistics: {
158
+ buy: StatisticsData;
159
+ sell: StatisticsData;
160
+ };
161
+ type: 'market-v2';
162
+ }
163
+
164
+ export interface TraderInfo {
165
+ ingameName: string;
166
+ platinum: number;
167
+ quantity: number;
168
+ status: UserStatus;
169
+ activity?: string;
170
+ reputation?: number;
171
+ platform?: Platform;
172
+ crossplay?: boolean;
173
+ }
174
+
175
+ export interface QueryOptions {
176
+ platform: Platform;
177
+ successfulQuery?: () => void;
178
+ rank?: number;
179
+ ranks?: number[];
180
+ rankLt?: number;
181
+ charges?: number;
182
+ chargesLt?: number;
183
+ amberStars?: number;
184
+ amberStarsLt?: number;
185
+ cyanStars?: number;
186
+ cyanStarsLt?: number;
187
+ subtype?: string;
188
+ }
189
+
190
+ /** Options for filtering price checks by mod rank and other order modifiers. */
191
+ export type PriceCheckOptions = Omit<QueryOptions, 'platform' | 'successfulQuery'>;
192
+
193
+ export interface GetTopOrdersOptions extends QueryOptions {
194
+ platform: Platform;
195
+ }
196
+
197
+ export interface CalculateStatisticsOptions {
198
+ type?: OrderType;
199
+ onlineOnly?: boolean;
200
+ includeOutliers?: boolean;
201
+ }
202
+
203
+ export interface GetBestOrdersOptions {
204
+ limit?: number;
205
+ onlineOnly?: boolean;
206
+ }
207
+
208
+ export class Item {
209
+ id: string;
210
+ slug: string;
211
+ name: string;
212
+ description?: string;
213
+ wikiLink?: string;
214
+ tags: string[];
215
+ gameRef?: string;
216
+ rarity?: Rarity;
217
+ thumb?: string;
218
+ icon?: string;
219
+ subIcon?: string;
220
+ tradingTax?: number;
221
+ ducats?: number;
222
+ vosfor?: number;
223
+ baseEndo?: number;
224
+ endoMultiplier?: number;
225
+ reqMasteryRank?: number;
226
+ maxRank?: number;
227
+ maxCharges?: number;
228
+ maxAmberStars?: number;
229
+ maxCyanStars?: number;
230
+ bulkTradable: boolean;
231
+ subtypes: string[];
232
+ tradable?: boolean;
233
+ vaulted: boolean;
234
+ setRoot?: boolean;
235
+ setParts: string[];
236
+ quantityInSet?: number;
237
+ i18n: I18nData;
238
+ locale: Language;
239
+ type: 'market-v2';
240
+
241
+ constructor(data: ItemData, locale?: Language);
242
+ getLocalized(field: string, lang?: Language): unknown;
243
+ getIconUrl(baseUrl?: string): string | null;
244
+ getThumbUrl(baseUrl?: string): string | null;
245
+ isPartOfSet(): boolean;
246
+ isVaulted(): boolean;
247
+ toJSON(): ItemData;
248
+ toString(): string;
249
+ }
250
+
251
+ export class OrderUser {
252
+ id: string;
253
+ ingameName: string;
254
+ avatar?: string;
255
+ reputation: number;
256
+ locale?: string;
257
+ platform?: Platform;
258
+ crossplay: boolean;
259
+ status?: UserStatus;
260
+ activity?: UserActivity;
261
+ lastSeen: Date | null;
262
+
263
+ constructor(data: OrderUserData);
264
+ isOnline(): boolean;
265
+ getActivityDescription(): string | null;
266
+ getStatusEmoji(): string;
267
+ toJSON(): OrderUserData;
268
+ }
269
+
270
+ export class Order {
271
+ id: string;
272
+ type: OrderType;
273
+ platinum: number;
274
+ quantity: number;
275
+ perTrade?: boolean;
276
+ rank?: number;
277
+ charges?: number;
278
+ subtype?: string;
279
+ amberStars?: number;
280
+ cyanStars?: number;
281
+ visible: boolean;
282
+ createdAt: Date | null;
283
+ updatedAt: Date | null;
284
+ itemId?: string;
285
+ group?: string;
286
+ user: OrderUser | null;
287
+
288
+ constructor(data: OrderData);
289
+ isUserOnline(): boolean;
290
+ isBuyOrder(): boolean;
291
+ isSellOrder(): boolean;
292
+ getAgeHours(): number;
293
+ toJSON(): OrderData;
294
+ toString(): string;
295
+ }
296
+
297
+ export class SummaryV2 {
298
+ name: string;
299
+ slug: string;
300
+ thumbnail: string;
301
+ partThumb?: string;
302
+ icon?: string;
303
+ tradingTax: number;
304
+ ducats: number;
305
+ vosfor: number;
306
+ masteryLevel?: number;
307
+ tradable?: boolean;
308
+ vaulted: boolean;
309
+ wikiUrl?: string;
310
+ description: string;
311
+ codex: string;
312
+ url: string;
313
+ tags: string[];
314
+ prices: SummaryPrices;
315
+ orders: {
316
+ buy: Order[];
317
+ sell: Order[];
318
+ };
319
+ statistics: {
320
+ buy: StatisticsData;
321
+ sell: StatisticsData;
322
+ };
323
+ type: 'market-v2';
324
+
325
+ constructor(
326
+ item: Item,
327
+ orders: { buy: Order[]; sell: Order[] },
328
+ statistics: { buy: StatisticsData; sell: StatisticsData }
329
+ );
330
+ getOnlineSellers(limit?: number): TraderInfo[];
331
+ getOnlineBuyers(limit?: number): TraderInfo[];
332
+ toString(opt?: 'codex' | 'item' | 'location' | 'traders' | 'all'): string;
333
+ pad(str: string, length?: number, character?: string): string;
334
+ }
335
+
336
+ export interface HttpClientOptions {
337
+ baseURL?: string;
338
+ timeout?: number;
339
+ locale?: Language;
340
+ logger?: Logger;
341
+ token?: string;
342
+ headers?: Record<string, string>;
343
+ }
344
+
345
+ export interface HttpClient {
346
+ get(
347
+ path: string,
348
+ options?: { platform?: Platform; locale?: Language; query?: Record<string, unknown> }
349
+ ): Promise<unknown>;
350
+ post(path: string, body: unknown, options?: { platform?: Platform; locale?: Language }): Promise<unknown>;
351
+ setLocale(locale: Language): void;
352
+ setTimeout(timeout: number): void;
353
+ }
354
+
355
+ export interface CacheOptions {
356
+ maxSize?: number;
357
+ ttl?: number;
358
+ cacheId?: string;
359
+ persistent?: boolean;
360
+ logger?: Logger;
361
+ }
362
+
363
+ export interface VersionedCache {
364
+ get(key: string, collection: string, fetchFn: () => Promise<unknown>): Promise<unknown>;
365
+ set(key: string, value: unknown, collection?: string): void;
366
+ clear(): void;
367
+ delete(key: string): void;
368
+ size(): number;
369
+ has(key: string): boolean;
370
+ checkVersions(): Promise<VersionedCacheVersionData>;
371
+ shouldRefresh(collection: string): Promise<boolean>;
372
+ refresh(key: string, collection: string, fetchFn: () => Promise<unknown>): Promise<unknown>;
373
+ }
374
+
375
+ export interface VersionedCacheVersionData {
376
+ apiVersion?: string;
377
+ data?: {
378
+ collections?: Record<string, string>;
379
+ [key: string]: unknown;
380
+ };
381
+ }
382
+
383
+ export interface MarketFetcherV2Options {
384
+ locale?: Language;
385
+ timeout?: number;
386
+ logger?: Logger;
387
+ cacheSize?: number;
388
+ ordersCacheSize?: number;
389
+ cacheTTL?: number;
390
+ baseURL?: string;
391
+ }
392
+
393
+ export interface MarketFetcherV2 {
394
+ locale: Language;
395
+ logger: Logger;
396
+
397
+ getItems(): Promise<Item[]>;
398
+ getItemBySlug(slug: string): Promise<Item>;
399
+ getItemSet(slug: string): Promise<{ id: string; items: Item[] }>;
400
+
401
+ getTopOrders(slug: string, options: GetTopOrdersOptions): Promise<{ buy: Order[]; sell: Order[] }>;
402
+ getAllOrders(slug: string, platform: Platform): Promise<Order[]>;
403
+ getRecentOrders(platform: Platform): Promise<Order[]>;
404
+
405
+ calculateStatistics(orders: Order[], options?: CalculateStatisticsOptions): StatisticsData;
406
+ getBestOrders(orders: Order[], options?: GetBestOrdersOptions): { buy: Order[]; sell: Order[] };
407
+ formatPriceRange(stats: StatisticsData): string;
408
+ formatStatistics(stats: StatisticsData, type?: OrderType): string;
409
+
410
+ queryMarket(query: string, options: QueryOptions): Promise<SummaryV2[]>;
411
+ priceCheckQuery(query: string, platform: Platform, options?: PriceCheckOptions): Promise<SummaryV2[]>;
412
+
413
+ clearCache(): void;
414
+ checkVersions(): Promise<VersionedCacheVersionData>;
415
+ normalizePlatform(platform: string): string;
416
+ setLocale(locale: Language): void;
417
+ stop(): void;
418
+ }
419
+
420
+ export interface PriceCheckQuerierOptions {
421
+ logger?: Logger;
422
+ marketCache?: MarketFetcherV2;
423
+ skipMarket?: boolean;
424
+ }
425
+
426
+ export interface PriceCheckQueryResult {
427
+ query: string;
428
+ platform: Platform;
429
+ results: SummaryV2[];
430
+ apiVersion: 'v1' | 'v2';
431
+ }
432
+
433
+ export interface DiscordEmbed {
434
+ type: 'rich';
435
+ title: string;
436
+ color: number;
437
+ url: string;
438
+ fields: DiscordEmbedField[];
439
+ thumbnail?: DiscordEmbedThumbnail;
440
+ footer?: DiscordEmbedFooter;
441
+ }
442
+
443
+ export interface DiscordEmbedField {
444
+ name: string;
445
+ value: string;
446
+ inline?: boolean;
447
+ }
448
+
449
+ export interface DiscordEmbedThumbnail {
450
+ url: string;
451
+ }
452
+
453
+ export interface DiscordEmbedFooter {
454
+ text: string;
455
+ icon_url?: string;
456
+ }
457
+
458
+ export class PriceCheckQuerier {
459
+ settings: Settings;
460
+ logger: Logger;
461
+ skipMarket: boolean;
462
+ marketFetcher: MarketFetcherV2 | null;
463
+ apiVersion: 'v1' | 'v2';
464
+ creator: AttachmentCreator;
465
+
466
+ constructor(options?: PriceCheckQuerierOptions);
467
+ priceCheckQuery(query: string, platform?: Platform, options?: PriceCheckOptions): Promise<SummaryV2[]>;
468
+ priceCheckQueryString(
469
+ query: string,
470
+ priorResults?: SummaryV2[],
471
+ platform?: Platform,
472
+ options?: PriceCheckOptions
473
+ ): Promise<string>;
474
+ priceCheckQueryAttachment(
475
+ query: string,
476
+ priorResults?: SummaryV2[],
477
+ platform?: Platform,
478
+ options?: PriceCheckOptions
479
+ ): Promise<DiscordEmbed[]>;
480
+ stopUpdating(): Promise<void>;
481
+ }
482
+
483
+ export interface AttachmentCreator {
484
+ attachmentFromComponents(components: SummaryV2[], query: string, platform?: Platform): DiscordEmbed;
485
+ }
486
+
487
+ export interface Settings {
488
+ urls: {
489
+ market: string;
490
+ marketAssets: string;
491
+ };
492
+ platforms: {
493
+ pc: Platform;
494
+ ps4: Platform;
495
+ playstation: Platform;
496
+ xbone: Platform;
497
+ xbox: Platform;
498
+ xb1: Platform;
499
+ swi: Platform;
500
+ switch: Platform;
501
+ ns: Platform;
502
+ market: Record<string, Platform>;
503
+ };
504
+ timeouts: {
505
+ market: number;
506
+ };
507
+ defaultString: string;
508
+ lookupAlias(platformAlias: string, market?: boolean): Platform | undefined;
509
+ }
510
+
511
+ export interface StatisticsCalculator {
512
+ calculateStatistics(orders: Order[], options?: CalculateStatisticsOptions): StatisticsData;
513
+ getBestOrders(orders: Order[], options?: GetBestOrdersOptions): { buy: Order[]; sell: Order[] };
514
+ formatPriceRange(stats: StatisticsData): string;
515
+ formatStatistics(stats: StatisticsData, type?: OrderType): string;
516
+ }
517
+
518
+ export { SummaryV2 as Summary };
519
+
520
+ export default PriceCheckQuerier;
521
+
522
+ export as namespace NexusQuery;