@wfcd/relics 2.0.0 → 2.0.2

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.js CHANGED
@@ -19,6 +19,10 @@ var __copyProps = (to, from, except, desc) => {
19
19
  return to;
20
20
  };
21
21
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
26
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
27
  mod
24
28
  ));
@@ -98,6 +102,10 @@ var Generator = class {
98
102
  constructor() {
99
103
  this.relics = [];
100
104
  }
105
+ /**
106
+ * Main function to fetch and generate the relic data
107
+ * @returns {Promise<Array<TitaniaRelic>>} The Relics data array
108
+ */
101
109
  async generate() {
102
110
  Logger_default.log("Starting Generation");
103
111
  await this.fetchRawData();
@@ -105,6 +113,9 @@ var Generator = class {
105
113
  this.generateTitaniaRelics();
106
114
  return this.relics;
107
115
  }
116
+ /**
117
+ * Fetches all required data from WFCD and WFM.
118
+ */
108
119
  async fetchRawData() {
109
120
  var _a;
110
121
  const relicRequest = await (0, import_node_fetch.default)(Config_default.warframeRelicDropUrl);
@@ -126,6 +137,11 @@ var Generator = class {
126
137
  }
127
138
  this.wfcdItems = await wfcdItemRequest.json();
128
139
  }
140
+ /**
141
+ * Generates the relic data
142
+ * uses WFCD/warframe-drop-data to check what relics exist,
143
+ * and adds information from WFCD/warframe-items and WFM
144
+ */
129
145
  generateTitaniaRelics() {
130
146
  if (typeof this.relicsRaw === "undefined" || typeof this.wfmItems === "undefined") {
131
147
  Logger_default.log("Failed to load relics/item data");
@@ -140,6 +156,12 @@ var Generator = class {
140
156
  }
141
157
  Logger_default.debug(`Finished parsing ${this.relics.length} relics`);
142
158
  }
159
+ /**
160
+ * Writes the fully generated data to disk.
161
+ * @param {string} dataDir Directory to store the relic data in. Default: ../data/
162
+ * @param {string} fileName Filename base ex: "Relics" becomes "Relics.json" and "Relics.min.json". Default: "Relics"
163
+ * @param {boolean} generateMin True if a minified json should be generated too. Default: true
164
+ */
143
165
  async writeData(dataDir, fileName, generateMin) {
144
166
  const DataDir = dataDir ?? import_node_path.default.join(__dirname, "..", "data");
145
167
  const RelicPath = fileName ? import_node_path.default.join(DataDir, `${fileName}.json`) : import_node_path.default.join(DataDir, "Relics.json");
@@ -149,6 +171,11 @@ var Generator = class {
149
171
  await import_promises.default.writeFile(RelicMinPath, JSON.stringify(this.relics));
150
172
  }
151
173
  }
174
+ /**
175
+ * Generates a single relic from all available data
176
+ * @param {WFCDRelic} rawRelic relic to pull Titania data from
177
+ * @returns {TitaniaRelicReward}
178
+ */
152
179
  generateTitaniaRelic(rawRelic) {
153
180
  var _a, _b;
154
181
  const name = `${rawRelic.tier} ${rawRelic.relicName}`;
@@ -158,7 +185,10 @@ var Generator = class {
158
185
  const { rarity } = rawReward;
159
186
  const wfmInfo = (_a2 = this.wfmItems) == null ? void 0 : _a2.payload.items.find((x) => x.item_name === rawReward.itemName);
160
187
  const isSpecial = ["Forma", "Kuva", "Exilus", "Riven"].find(
161
- (x) => rawReward.itemName.toLowerCase().includes(x.toLowerCase())
188
+ (x) => (
189
+ // eslint-disable-next-line @typescript-eslint/comma-dangle
190
+ rawReward.itemName.toLowerCase().includes(x.toLowerCase())
191
+ )
162
192
  );
163
193
  if (!(wfmInfo || isSpecial)) {
164
194
  Logger_default.debug(`Failed to find wfm item for ${rawReward.itemName}`);
@@ -196,6 +226,9 @@ var Generator = class {
196
226
  ...(wfm == null ? void 0 : wfm.id) && (wfm == null ? void 0 : wfm.url_name) && { warframeMarket: { id: wfm == null ? void 0 : wfm.id, urlName: wfm == null ? void 0 : wfm.url_name } }
197
227
  };
198
228
  }
229
+ /**
230
+ * Filters WFCD's relic data to only include Intact variants, since we just need the base.
231
+ */
199
232
  filterWFCDRelics() {
200
233
  var _a, _b, _c;
201
234
  const before = ((_a = this.relicsRaw) == null ? void 0 : _a.length) || 0;
@@ -213,12 +246,20 @@ var VersionManager = class {
213
246
  versionPath;
214
247
  versionRawPath;
215
248
  hashPath;
249
+ /**
250
+ * Creates a new VersionManager instance.
251
+ * @param {string} dataDir Folder to write version information to.
252
+ * @constructor
253
+ */
216
254
  constructor(dataDir) {
217
255
  const DataDir = dataDir ?? import_node_path2.default.join(__dirname, "..", "data");
218
256
  this.versionPath = import_node_path2.default.join(DataDir, "version.json");
219
257
  this.versionRawPath = import_node_path2.default.join(DataDir, "version.txt");
220
258
  this.hashPath = import_node_path2.default.join(DataDir, "hash.json");
221
259
  }
260
+ /**
261
+ * Checks if the current data needs an update
262
+ */
222
263
  async updateNeeded() {
223
264
  const infoReq = await (0, import_node_fetch2.default)(Config_default.warframeRelicDropInfoUrl);
224
265
  if (!infoReq.ok) {
@@ -233,6 +274,10 @@ var VersionManager = class {
233
274
  return true;
234
275
  }
235
276
  }
277
+ /**
278
+ * Writes both game and drop version metadata
279
+ * @param {number} timestamp Timestamp the build was started at
280
+ */
236
281
  async writeVersion(timestamp) {
237
282
  const patchLogsReq = await (0, import_node_fetch2.default)(Config_default.warframePatchlogsUrl);
238
283
  if (!patchLogsReq.ok) {
package/dist/index.mjs CHANGED
@@ -67,6 +67,10 @@ var Generator = class {
67
67
  constructor() {
68
68
  this.relics = [];
69
69
  }
70
+ /**
71
+ * Main function to fetch and generate the relic data
72
+ * @returns {Promise<Array<TitaniaRelic>>} The Relics data array
73
+ */
70
74
  async generate() {
71
75
  Logger_default.log("Starting Generation");
72
76
  await this.fetchRawData();
@@ -74,6 +78,9 @@ var Generator = class {
74
78
  this.generateTitaniaRelics();
75
79
  return this.relics;
76
80
  }
81
+ /**
82
+ * Fetches all required data from WFCD and WFM.
83
+ */
77
84
  async fetchRawData() {
78
85
  var _a;
79
86
  const relicRequest = await fetch(Config_default.warframeRelicDropUrl);
@@ -95,6 +102,11 @@ var Generator = class {
95
102
  }
96
103
  this.wfcdItems = await wfcdItemRequest.json();
97
104
  }
105
+ /**
106
+ * Generates the relic data
107
+ * uses WFCD/warframe-drop-data to check what relics exist,
108
+ * and adds information from WFCD/warframe-items and WFM
109
+ */
98
110
  generateTitaniaRelics() {
99
111
  if (typeof this.relicsRaw === "undefined" || typeof this.wfmItems === "undefined") {
100
112
  Logger_default.log("Failed to load relics/item data");
@@ -109,6 +121,12 @@ var Generator = class {
109
121
  }
110
122
  Logger_default.debug(`Finished parsing ${this.relics.length} relics`);
111
123
  }
124
+ /**
125
+ * Writes the fully generated data to disk.
126
+ * @param {string} dataDir Directory to store the relic data in. Default: ../data/
127
+ * @param {string} fileName Filename base ex: "Relics" becomes "Relics.json" and "Relics.min.json". Default: "Relics"
128
+ * @param {boolean} generateMin True if a minified json should be generated too. Default: true
129
+ */
112
130
  async writeData(dataDir, fileName, generateMin) {
113
131
  const DataDir = dataDir ?? path.join(__dirname, "..", "data");
114
132
  const RelicPath = fileName ? path.join(DataDir, `${fileName}.json`) : path.join(DataDir, "Relics.json");
@@ -118,6 +136,11 @@ var Generator = class {
118
136
  await fs.writeFile(RelicMinPath, JSON.stringify(this.relics));
119
137
  }
120
138
  }
139
+ /**
140
+ * Generates a single relic from all available data
141
+ * @param {WFCDRelic} rawRelic relic to pull Titania data from
142
+ * @returns {TitaniaRelicReward}
143
+ */
121
144
  generateTitaniaRelic(rawRelic) {
122
145
  var _a, _b;
123
146
  const name = `${rawRelic.tier} ${rawRelic.relicName}`;
@@ -127,7 +150,10 @@ var Generator = class {
127
150
  const { rarity } = rawReward;
128
151
  const wfmInfo = (_a2 = this.wfmItems) == null ? void 0 : _a2.payload.items.find((x) => x.item_name === rawReward.itemName);
129
152
  const isSpecial = ["Forma", "Kuva", "Exilus", "Riven"].find(
130
- (x) => rawReward.itemName.toLowerCase().includes(x.toLowerCase())
153
+ (x) => (
154
+ // eslint-disable-next-line @typescript-eslint/comma-dangle
155
+ rawReward.itemName.toLowerCase().includes(x.toLowerCase())
156
+ )
131
157
  );
132
158
  if (!(wfmInfo || isSpecial)) {
133
159
  Logger_default.debug(`Failed to find wfm item for ${rawReward.itemName}`);
@@ -165,6 +191,9 @@ var Generator = class {
165
191
  ...(wfm == null ? void 0 : wfm.id) && (wfm == null ? void 0 : wfm.url_name) && { warframeMarket: { id: wfm == null ? void 0 : wfm.id, urlName: wfm == null ? void 0 : wfm.url_name } }
166
192
  };
167
193
  }
194
+ /**
195
+ * Filters WFCD's relic data to only include Intact variants, since we just need the base.
196
+ */
168
197
  filterWFCDRelics() {
169
198
  var _a, _b, _c;
170
199
  const before = ((_a = this.relicsRaw) == null ? void 0 : _a.length) || 0;
@@ -182,12 +211,20 @@ var VersionManager = class {
182
211
  versionPath;
183
212
  versionRawPath;
184
213
  hashPath;
214
+ /**
215
+ * Creates a new VersionManager instance.
216
+ * @param {string} dataDir Folder to write version information to.
217
+ * @constructor
218
+ */
185
219
  constructor(dataDir) {
186
220
  const DataDir = dataDir ?? path2.join(__dirname, "..", "data");
187
221
  this.versionPath = path2.join(DataDir, "version.json");
188
222
  this.versionRawPath = path2.join(DataDir, "version.txt");
189
223
  this.hashPath = path2.join(DataDir, "hash.json");
190
224
  }
225
+ /**
226
+ * Checks if the current data needs an update
227
+ */
191
228
  async updateNeeded() {
192
229
  const infoReq = await fetch2(Config_default.warframeRelicDropInfoUrl);
193
230
  if (!infoReq.ok) {
@@ -202,6 +239,10 @@ var VersionManager = class {
202
239
  return true;
203
240
  }
204
241
  }
242
+ /**
243
+ * Writes both game and drop version metadata
244
+ * @param {number} timestamp Timestamp the build was started at
245
+ */
205
246
  async writeVersion(timestamp) {
206
247
  const patchLogsReq = await fetch2(Config_default.warframePatchlogsUrl);
207
248
  if (!patchLogsReq.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wfcd/relics",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Relic Data for Warframe",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -18,7 +18,7 @@
18
18
  "coverage": "npm test && nyc report --reporter=text-lcov | coveralls",
19
19
  "lint": "eslint .",
20
20
  "lint:fix": "eslint . --fix",
21
- "postinstall": "install-peerdeps @wfcd/eslint-config@^1.2.0 -S",
21
+ "postinstall": "install-peerdeps @wfcd/eslint-config@^1.3.3 -S",
22
22
  "prepack": "npm run build",
23
23
  "start": "npm run build && node dist/Build.js",
24
24
  "test": "nyc mocha",
@@ -46,7 +46,7 @@
46
46
  "@wfcd/eslint-config": "^1.2.0",
47
47
  "chai": "^4.3.6",
48
48
  "coveralls": "^3.1.1",
49
- "install-peerdeps": "^3.0.3",
49
+ "install-peerdeps": "^2.0.3",
50
50
  "mocha": "^10.0.0",
51
51
  "nyc": "^15.1.0",
52
52
  "precommit-hook": "^3.0.0",
@@ -54,7 +54,7 @@
54
54
  "ts-node": "^10.9.1",
55
55
  "tsconfig-paths": "^4.1.0",
56
56
  "tsup": "^6.3.0",
57
- "typescript": "^4.7.4"
57
+ "typescript": "^5.0.4"
58
58
  },
59
59
  "dependencies": {
60
60
  "node-fetch": "^2.6.7",
@@ -68,7 +68,7 @@
68
68
  "@wfcd/eslint-config/typescript"
69
69
  ],
70
70
  "parserOptions": {
71
- "project": "./tsconfig.json"
71
+ "project": "tsconfig.json"
72
72
  }
73
73
  },
74
74
  "prettier": "@wfcd/eslint-config/prettier",