warframe-nexus-query 2.3.10 → 3.0.1

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.
@@ -1,197 +0,0 @@
1
- /**
2
- * User information embedded in orders
3
- */
4
- class OrderUser {
5
- constructor(data) {
6
- this.id = data.id;
7
- this.ingameName = data.ingameName;
8
- this.avatar = data.avatar;
9
- this.reputation = data.reputation || 0;
10
- this.locale = data.locale;
11
- this.platform = data.platform;
12
- this.crossplay = data.crossplay || false;
13
- this.status = data.status; // 'online' | 'ingame' | 'offline' | 'invisible'
14
- this.activity = data.activity; // { type, details, startedAt }
15
- this.lastSeen = data.lastSeen ? new Date(data.lastSeen) : null;
16
- }
17
-
18
- /**
19
- * Check if user is online
20
- * @returns {boolean}
21
- */
22
- isOnline() {
23
- return this.status === 'online' || this.status === 'ingame';
24
- }
25
-
26
- /**
27
- * Get activity description
28
- * @returns {string}
29
- */
30
- getActivityDescription() {
31
- if (!this.activity || !this.activity.type) return null;
32
-
33
- const { type, details } = this.activity;
34
-
35
- switch (type) {
36
- case 'ON_MISSION':
37
- return details ? `On Mission: ${details}` : 'On Mission';
38
- case 'IN_DOJO':
39
- return 'In Dojo';
40
- case 'IN_ORBITER':
41
- return 'In Orbiter';
42
- case 'IN_RELAY':
43
- return details ? `In Relay: ${details}` : 'In Relay';
44
- case 'IDLE':
45
- return 'Idle';
46
- default:
47
- return null;
48
- }
49
- }
50
-
51
- /**
52
- * Get status emoji
53
- * @returns {string}
54
- */
55
- getStatusEmoji() {
56
- switch (this.status) {
57
- case 'online':
58
- return '🟢';
59
- case 'ingame':
60
- return '🎮';
61
- case 'offline':
62
- return '⚫';
63
- case 'invisible':
64
- return '👻';
65
- default:
66
- return '❓';
67
- }
68
- }
69
-
70
- /**
71
- * Convert to JSON
72
- * @returns {Object}
73
- */
74
- toJSON() {
75
- return {
76
- id: this.id,
77
- ingameName: this.ingameName,
78
- avatar: this.avatar,
79
- reputation: this.reputation,
80
- locale: this.locale,
81
- platform: this.platform,
82
- crossplay: this.crossplay,
83
- status: this.status,
84
- activity: this.activity,
85
- lastSeen: this.lastSeen?.toISOString(),
86
- };
87
- }
88
- }
89
-
90
- /**
91
- * Order model for Warframe Market API v2
92
- * Represents a buy or sell order with optional user information
93
- */
94
- export default class Order {
95
- /**
96
- * @param {Object} data - Raw order data from API
97
- */
98
- constructor(data) {
99
- this.id = data.id;
100
- this.type = data.type; // 'buy' | 'sell'
101
- this.platinum = data.platinum;
102
- this.quantity = data.quantity;
103
- this.perTrade = data.perTrade;
104
-
105
- // Item modifiers
106
- this.rank = data.rank;
107
- this.charges = data.charges;
108
- this.subtype = data.subtype;
109
- this.amberStars = data.amberStars;
110
- this.cyanStars = data.cyanStars;
111
-
112
- // Metadata
113
- this.visible = data.visible;
114
- this.createdAt = data.createdAt ? new Date(data.createdAt) : null;
115
- this.updatedAt = data.updatedAt ? new Date(data.updatedAt) : null;
116
- this.itemId = data.itemId;
117
- this.group = data.group;
118
-
119
- // User data (if OrderWithUser)
120
- this.user = data.user ? new OrderUser(data.user) : null;
121
- }
122
-
123
- /**
124
- * Check if order is from an online user
125
- * @returns {boolean}
126
- */
127
- isUserOnline() {
128
- if (!this.user) return false;
129
- return this.user.status === 'online' || this.user.status === 'ingame';
130
- }
131
-
132
- /**
133
- * Check if order is buy type
134
- * @returns {boolean}
135
- */
136
- isBuyOrder() {
137
- return this.type === 'buy';
138
- }
139
-
140
- /**
141
- * Check if order is sell type
142
- * @returns {boolean}
143
- */
144
- isSellOrder() {
145
- return this.type === 'sell';
146
- }
147
-
148
- /**
149
- * Get order age in hours
150
- * @returns {number}
151
- */
152
- getAgeHours() {
153
- if (!this.updatedAt) return 0;
154
- return (Date.now() - this.updatedAt.getTime()) / (1000 * 60 * 60);
155
- }
156
-
157
- /**
158
- * Convert to JSON
159
- * @returns {Object}
160
- */
161
- toJSON() {
162
- return {
163
- id: this.id,
164
- type: this.type,
165
- platinum: this.platinum,
166
- quantity: this.quantity,
167
- perTrade: this.perTrade,
168
- rank: this.rank,
169
- charges: this.charges,
170
- subtype: this.subtype,
171
- amberStars: this.amberStars,
172
- cyanStars: this.cyanStars,
173
- visible: this.visible,
174
- createdAt: this.createdAt?.toISOString(),
175
- updatedAt: this.updatedAt?.toISOString(),
176
- itemId: this.itemId,
177
- group: this.group,
178
- user: this.user?.toJSON(),
179
- };
180
- }
181
-
182
- /**
183
- * Convert to string representation
184
- * @returns {string}
185
- */
186
- toString() {
187
- const userStr = this.user ? ` by ${this.user.ingameName}` : '';
188
- const modifiers = [];
189
- if (this.rank != null) modifiers.push(`R${this.rank}`);
190
- if (this.subtype) modifiers.push(this.subtype);
191
- const modStr = modifiers.length > 0 ? ` (${modifiers.join(', ')})` : '';
192
-
193
- return `${this.type.toUpperCase()}: ${this.platinum}p x${this.quantity}${modStr}${userStr}`;
194
- }
195
- }
196
-
197
- export { OrderUser };
@@ -1,165 +0,0 @@
1
- /**
2
- * Summary model for v2 API
3
- * Compatible with v1 Summary but with v2 data structures
4
- */
5
-
6
- import { ASSETS_BASE_URL } from '../constants.js';
7
-
8
- export default class SummaryV2 {
9
- /**
10
- * Create a summary from v2 Item and Order data
11
- * @param {Item} item - Item object
12
- * @param {Object} orders - Orders object with { buy, sell }
13
- * @param {Object} statistics - Statistics object with { buy, sell }
14
- */
15
- constructor(item, orders, statistics) {
16
- // Basic item info
17
- this.name = item.name;
18
- this.slug = item.slug;
19
- this.thumbnail = item.getThumbUrl(ASSETS_BASE_URL);
20
- this.partThumb = item.subIcon ? `${ASSETS_BASE_URL}${item.subIcon}` : this.thumbnail;
21
- this.icon = item.getIconUrl(ASSETS_BASE_URL);
22
-
23
- // Item metadata
24
- this.tradingTax = item.tradingTax || 0;
25
- this.ducats = item.ducats || 0;
26
- this.vosfor = item.vosfor || 0;
27
- this.masteryLevel = item.reqMasteryRank;
28
- this.tradable = item.tradable;
29
- this.vaulted = item.vaulted;
30
-
31
- // Links and descriptions
32
- this.wikiUrl = item.wikiLink;
33
- this.description = item.description || '';
34
- this.codex = this.description; // v1 compatibility
35
- this.url = `https://warframe.market/items/${item.slug}`;
36
-
37
- // Tags
38
- this.tags = item.tags || [];
39
-
40
- // Prices and statistics (from v2 orders)
41
- this.prices = {
42
- soldCount: statistics.sell.orderCount,
43
- soldPrice: statistics.sell.median,
44
- minimum: statistics.sell.min,
45
- maximum: statistics.sell.max,
46
- average: statistics.sell.avg,
47
- volume: statistics.sell.volume,
48
- };
49
-
50
- // Store full orders and statistics
51
- this.orders = orders;
52
- this.statistics = statistics;
53
-
54
- // Type marker
55
- this.type = 'market-v2';
56
- }
57
-
58
- /**
59
- * Get best online sellers
60
- * @param {number} limit - Number of sellers to return
61
- * @returns {Array<{ingameName: string, platinum: number, quantity: number, status: string, activity: string}>}
62
- */
63
- getOnlineSellers(limit = 5) {
64
- return this.orders.sell
65
- .filter((order) => order.isUserOnline())
66
- .slice(0, limit)
67
- .map((order) => ({
68
- ingameName: order.user.ingameName,
69
- platinum: order.platinum,
70
- quantity: order.quantity,
71
- status: order.user.status,
72
- activity: order.user.getActivityDescription(),
73
- reputation: order.user.reputation,
74
- platform: order.user.platform,
75
- crossplay: order.user.crossplay,
76
- }));
77
- }
78
-
79
- /**
80
- * Get best online buyers
81
- * @param {number} limit - Number of buyers to return
82
- * @returns {Array<{ingameName: string, platinum: number, quantity: number, status: string, activity: string}>}
83
- */
84
- getOnlineBuyers(limit = 5) {
85
- return this.orders.buy
86
- .filter((order) => order.isUserOnline())
87
- .slice(0, limit)
88
- .map((order) => ({
89
- ingameName: order.user.ingameName,
90
- platinum: order.platinum,
91
- quantity: order.quantity,
92
- status: order.user.status,
93
- activity: order.user.getActivityDescription(),
94
- reputation: order.user.reputation,
95
- platform: order.user.platform,
96
- crossplay: order.user.crossplay,
97
- }));
98
- }
99
-
100
- /**
101
- * String representation (v1 compatible)
102
- * @param {string} opt - Option: 'codex', 'item', 'location', 'all'
103
- * @returns {string}
104
- */
105
- toString(opt = 'item') {
106
- let value = `**${this.name}**\n`;
107
-
108
- if (opt === 'codex' || opt === 'all') {
109
- value += `\`\`\`\nCodex: ${this.codex}\n\`\`\`\n`;
110
- }
111
-
112
- if (opt === 'item' || opt === 'all') {
113
- value += '```\n';
114
- if (this.masteryLevel) {
115
- value += `Requires: MR ${this.masteryLevel} | `;
116
- }
117
- value += `Tax: ${this.tradingTax}cr\n`;
118
- value += `Item is ${this.tradable ? '' : 'not '}tradable`;
119
- if (this.vaulted) {
120
- value += ' (VAULTED)';
121
- }
122
- value += '\n\n';
123
-
124
- // Sell statistics
125
- value += `${this.prices.soldCount} sellers (${this.prices.volume} items)\n`;
126
- value += `Median: ${this.prices.soldPrice}p | `;
127
- value += `Range: ${this.prices.minimum}p - ${this.prices.maximum}p\n`;
128
-
129
- // Buy statistics (if available)
130
- if (this.statistics.buy.orderCount > 0) {
131
- value += `\n${this.statistics.buy.orderCount} buyers\n`;
132
- value += `Median: ${this.statistics.buy.median}p | `;
133
- value += `Range: ${this.statistics.buy.min}p - ${this.statistics.buy.max}p\n`;
134
- }
135
-
136
- value += '```\n';
137
- }
138
-
139
- if (opt === 'traders' || opt === 'all') {
140
- const sellers = this.getOnlineSellers(3);
141
- if (sellers.length > 0) {
142
- value += '\n**Online Sellers:**\n';
143
- sellers.forEach((seller) => {
144
- const statusEmoji = seller.status === 'ingame' ? '🎮' : '🟢';
145
- const activity = seller.activity ? ` (${seller.activity})` : '';
146
- value += `${statusEmoji} ${seller.ingameName} - ${seller.platinum}p x${seller.quantity}${activity}\n`;
147
- });
148
- }
149
- }
150
-
151
- value += `\n${this.wikiUrl || this.url}`;
152
- return value;
153
- }
154
-
155
- /**
156
- * Padding helper (v1 compatibility)
157
- * @param {string} str - String to pad
158
- * @param {number} length - Target length
159
- * @param {string} character - Padding character
160
- * @returns {string}
161
- */
162
- pad(str, length = 10, character = ' ') {
163
- return str.padEnd(length, character);
164
- }
165
- }
@@ -1,137 +0,0 @@
1
- /**
2
- * TypeScript type definitions for Warframe Market API v2
3
- * @module types
4
- */
5
-
6
- export interface ItemData {
7
- id: string;
8
- slug: string;
9
- gameRef?: string;
10
- tags?: string[];
11
- tradingTax?: number;
12
- ducats?: number;
13
- vosfor?: number;
14
- masteryLevel?: number;
15
- maxRank?: number;
16
- i18n: {
17
- [lang: string]: {
18
- name: string;
19
- description?: string;
20
- icon?: string;
21
- thumb?: string;
22
- subIcon?: string;
23
- };
24
- };
25
- }
26
-
27
- export interface OrderUserData {
28
- id: string;
29
- ingameName: string;
30
- lastSeen?: string;
31
- reputation?: number;
32
- locale?: string;
33
- avatar?: string;
34
- status?: 'invisible' | 'offline' | 'online' | 'ingame';
35
- activity?: {
36
- type: string;
37
- string: string;
38
- };
39
- }
40
-
41
- export interface OrderData {
42
- id: string;
43
- platinum: number;
44
- quantity: number;
45
- orderType: 'buy' | 'sell';
46
- platform: string;
47
- creationDate: string;
48
- lastUpdate: string;
49
- visible: boolean;
50
- user: OrderUserData;
51
- region?: string;
52
- rank?: number;
53
- modRank?: number;
54
- charges?: number;
55
- amberStars?: number;
56
- subtype?: string;
57
- }
58
-
59
- export interface StatisticsData {
60
- median?: number;
61
- mean?: number;
62
- min?: number;
63
- max?: number;
64
- volume?: number;
65
- orderCount?: number;
66
- stdDev?: number;
67
- range?: number;
68
- }
69
-
70
- export interface SummaryData {
71
- name: string;
72
- slug: string;
73
- thumbnail: string;
74
- icon?: string;
75
- url: string;
76
- color: string;
77
- tradingTax: number;
78
- ducats?: number;
79
- vosfor?: number;
80
- masteryLevel?: number;
81
- type: 'market-v2';
82
- prices: {
83
- soldCount: number;
84
- soldPrice: number;
85
- minimum: number;
86
- maximum: number;
87
- volume: number;
88
- };
89
- orders: {
90
- buy: OrderData[];
91
- sell: OrderData[];
92
- };
93
- statistics: {
94
- buy: StatisticsData;
95
- sell: StatisticsData;
96
- };
97
- }
98
-
99
- export interface QueryOptions {
100
- platform: string;
101
- successfulQuery?: () => void;
102
- rank?: number;
103
- rankLt?: number;
104
- charges?: number;
105
- chargesLt?: number;
106
- amberStars?: number;
107
- amberStarsLt?: number;
108
- }
109
-
110
- export interface TraderInfo {
111
- ingameName: string;
112
- platinum: number;
113
- status?: string;
114
- activity?: string;
115
- }
116
-
117
- export interface MarketFetcherV2Options {
118
- locale?: string;
119
- timeout?: number;
120
- logger?: Console;
121
- cacheSize?: number;
122
- cacheTTL?: number;
123
- baseURL?: string;
124
- }
125
-
126
- export interface HttpClientOptions {
127
- baseURL?: string;
128
- timeout?: number;
129
- locale?: string;
130
- logger?: Console;
131
- }
132
-
133
- export interface CacheOptions {
134
- maxSize?: number;
135
- ttl?: number;
136
- logger?: Console;
137
- }