poe-api-manager 1.2.1 โ†’ 1.2.3

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.
@@ -0,0 +1,53 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ npm-publish:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: ๐Ÿ“š Checkout repository
16
+ uses: actions/checkout@v2
17
+
18
+ - run: ls
19
+
20
+ - name: Node
21
+ uses: actions/setup-node@v2
22
+ with:
23
+ node-version: '20'
24
+ registry-url: https://registry.npmjs.org
25
+
26
+ - name: ๐Ÿงช NPM ci
27
+ run: npm ci
28
+
29
+ - name: ๐Ÿ“ฆ Publish to NPM
30
+ run: npm publish
31
+ env:
32
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
33
+
34
+ - name: ๐Ÿš€ Get version and release name from package.json
35
+ id: version
36
+ run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"
37
+
38
+ - name: ๐Ÿš€ Get release name
39
+ id: release_name
40
+ run: echo "::set-output name=release_name::$(node -e 'console.log(require("./package.json").name)')"
41
+
42
+ - name: ๐Ÿš€ Generate Version
43
+ id: create-release
44
+ uses: actions/create-release@v1
45
+ env:
46
+ GITHUB_TOKEN: ${{ secrets.G_TOKEN }}
47
+ with:
48
+ tag_name: v${{ steps.version.outputs.version }}
49
+ release_name: ${{ steps.release_name.outputs.release_name }} v${{ steps.version.outputs.version }}
50
+ body: "[CHANGELOG](https://github.com/ayberkgezer/poe-api-manager/blob/main/CHANGELOG.md)"
51
+ draft: false
52
+ prerelease: false
53
+
package/Changelog.md CHANGED
@@ -1,4 +1,13 @@
1
1
  # Changelog
2
+ ## 1.2.3
3
+ - ๐Ÿš€ [Added] Coffins added to itemview.
4
+
5
+ ## 1.2.2
6
+ - ๐Ÿ› ๏ธ [Fixed] Control mechanisms in API calls have been improved for better error handling.
7
+ - ๐Ÿ”„ [Changed] Updated dependencies to their latest versions for improved security and performance.
8
+ - ๐Ÿš€ [Added] `getQuickCurrency()` has been added to the Currency class.
9
+
10
+
2
11
  ## 1.2.1
3
12
  - ๐Ÿ”„ [Update] Development was done with OOP. Classes have been changed.
4
13
  >There was no change in the scripts.
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  - [Introduction](#introduction)
11
- - [Overwiev](#overwiev)
11
+ - [Overview](#overview)
12
12
  - [Installation](#installation)
13
13
  - [Getting Started](#getting-started)
14
14
  - [poe.ninja](#ninjaapi)
@@ -29,7 +29,7 @@ The purpose of this library is to make the economic data in the Path of Exile ga
29
29
 
30
30
  > Note: This product is in no way affiliated with or endorsed by Grinding Gear Games, poe.ninja and poe.watch.
31
31
 
32
- ## Overwiev
32
+ ## Overview
33
33
 
34
34
  Permission to access two different services. poe.ninja and poe.watch
35
35
 
@@ -60,7 +60,7 @@ ninjaAPI.currencyView.currency.getData().then((data) => {
60
60
  console.log(data);
61
61
  });
62
62
  ```
63
- - getdata(requestedProperties) => The function filters the data as desired.
63
+ - getData(requestedProperties) => The function filters the data as desired.
64
64
  >Note: Enter [poe.ninja Document](https://github.com/ayberkgezer/poe.ninja-API-Document?tab=readme-ov-file#poeninja-api) to access the values for the filter.
65
65
  ```javascript
66
66
  //Filtered data is returned
@@ -68,6 +68,13 @@ ninjaAPI.currencyView.currency.getData(["id", "name", "icon"]).then((data) => {
68
68
  console.log(data);
69
69
  });
70
70
  ```
71
+ - getQuickCurrency() => This function returns the chaos value from the currency name. It returns "Divine Orb" chaos as the default value. currencyTypeName default "Divine Orb"
72
+ ```javascript
73
+ ninjaAPI.currencyView.currency.getQuickCurrency(currencyTypeName).then((data)=> {
74
+ console.log(data);
75
+ });
76
+ ```
77
+
71
78
  #### itemView
72
79
  What we can get here is as follows.
73
80
  - BaseType
@@ -4,9 +4,19 @@ const getData = require("./methods/getData");
4
4
  * Represents a base class for interacting with data.
5
5
  */
6
6
  class CurrencyBaseClass {
7
- #url;
8
- #type;
9
- #baseurl = "https://poe.ninja/api/data/";
7
+ /**
8
+ * The league name for which data is requested.
9
+ * @type {string}
10
+ * @private
11
+ */
12
+ #league;
13
+
14
+ /**
15
+ * The type of data.
16
+ * @type {string}
17
+ * @private
18
+ */
19
+ #typeName;
10
20
 
11
21
  /**
12
22
  * Constructs a new CurrencyBaseClass instance.
@@ -14,8 +24,8 @@ class CurrencyBaseClass {
14
24
  * @param {string} typeName - The type of data.
15
25
  */
16
26
  constructor(league, typeName) {
17
- this.#url = `${this.#baseurl}currencyoverview?league=${league}`;
18
- this.#type = `&type=${typeName}`;
27
+ this.#league = league;
28
+ this.#typeName = typeName;
19
29
  }
20
30
 
21
31
  /**
@@ -27,7 +37,7 @@ class CurrencyBaseClass {
27
37
  */
28
38
  async getData(requestedProperties) {
29
39
  try {
30
- return await getData(this.#url, this.#type, requestedProperties);
40
+ return await getData(this.#league, this.#typeName, requestedProperties);
31
41
  } catch (error) {
32
42
  throw new Error(`Error fetching CurrencyView data: ${error.message}`);
33
43
  }
@@ -1,17 +1,18 @@
1
1
  const axios = require("axios");
2
2
  const mergeData = require("./merge/mergeData");
3
+ const currencyUrlGenerator = require("../currencyUrlGenerator/CurrencyUrlGenerator");
3
4
 
4
5
  /**
5
6
  * Fetches data from a specified API endpoint, merges relevant data, and returns the result.
6
7
  *
7
- * @param {string} baseurl - The base URL of the API.
8
+ * @param {string} league - The game league for which to fetch currency data.
8
9
  * @param {string} type - The type of data to fetch. (e.g. "Currency", "Fragment")
9
10
  * @returns {Promise<Array<Object>>} - A promise that resolves to an array of merged objects containing both line and currency details.
10
11
  * @throws {Error} - Throws an error if there's an issue with the API response or data fetching process.
11
12
  */
12
- async function fetchData(baseurl, type) {
13
+ async function fetchData(league, type) {
13
14
  try {
14
- const url = `${baseurl}${type}`;
15
+ const url = currencyUrlGenerator(league, type);
15
16
  const response = await axios.get(url);
16
17
 
17
18
  if (response.data && response.data.lines && response.data.currencyDetails) {
@@ -23,7 +24,7 @@ async function fetchData(baseurl, type) {
23
24
  return mergedData;
24
25
  } else {
25
26
  throw new Error(
26
- "Invalid response format from POE Ninja API Currencyview"
27
+ "Invalid response format from POE Ninja API CurrencyView"
27
28
  );
28
29
  }
29
30
  } catch (error) {
@@ -1,16 +1,53 @@
1
1
  const CurrencyBaseClass = require("../../CurrencyBaseClass");
2
+ const getQuickCurrency = require("../../methods/getQuickCurrency");
2
3
 
3
4
  /**
4
5
  * Represents a module for interacting with currency data.
5
6
  * @extends CurrencyBaseClass
6
7
  */
7
8
  class CurrencyModule extends CurrencyBaseClass {
9
+ /**
10
+ * The league name for which currency data is requested.
11
+ * @type {string}
12
+ * @private
13
+ */
14
+ #league;
15
+ /**
16
+ * The type name for which currency data is requested.
17
+ * @type {string}
18
+ * @private
19
+ */
20
+ #typeName;
8
21
  /**
9
22
  * Constructs a new CurrencyModule instance.
10
23
  * @param {string} league - The league name for which currency data is requested.
11
24
  */
12
25
  constructor(league) {
13
- super(league, "Currency");
26
+ /**
27
+ * The type name for which currency data is requested.
28
+ * @type {string}
29
+ */
30
+ const type = "Currency";
31
+ super(league, type);
32
+ this.#league = league;
33
+ this.#typeName = type;
34
+ }
35
+ /**
36
+ * Fetches quick currency data for a given currency ID. Defaults to "Divine Orb" if no ID is provided.
37
+ * @param {string} currencyTypeName - The "currencyTypeName" of the currency to fetch data for. Defaults to "Divine Orb".
38
+ * @returns {Promise<{currencyTypeName: string, chaosEquivalent: number}>} A promise that resolves with the currency data, including the currency type name and its chaos equivalent.
39
+ * @throws {Error} Throws an error if fetching currency data fails.
40
+ */
41
+ async getQuickCurrency(currencyTypeName = "Divine Orb") {
42
+ try {
43
+ return await getQuickCurrency(
44
+ this.#league,
45
+ this.#typeName,
46
+ currencyTypeName
47
+ );
48
+ } catch (error) {
49
+ throw new Error(`Error fetching CurrencyData data: ${error.message}`);
50
+ }
14
51
  }
15
52
  }
16
53
 
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generates a URL based on league and type. poe.ninja (currencyView) API is used.
3
+ * @param {string} league - The league for which the URL is generated.
4
+ * @param {string} type - The type of data for which the URL is generated.
5
+ * @returns {string} - The generated URL.
6
+ */
7
+ module.exports = function urlGenerator(league, type) {
8
+ return `https://poe.ninja/api/data/currencyoverview?league=${league}&type=${type}`;
9
+ };
@@ -14,10 +14,10 @@ const filterProperties = require("../../../mainfunctions/filter/propertyFilter")
14
14
  * @function
15
15
  *
16
16
  */
17
- async function getData(url, type, requestedProperties) {
17
+ async function getData(league, type, requestedProperties) {
18
18
  try {
19
19
  // Fetch data using the fetchData function
20
- const fetchedData = await fetchData(url, type);
20
+ const fetchedData = await fetchData(league, type);
21
21
 
22
22
  // If requestedProperties are specified, filter the data based on those properties
23
23
  if (requestedProperties) {
@@ -0,0 +1,28 @@
1
+ const fetchCurrency = require("../currencyFetch/fetchCurrency");
2
+
3
+ /**
4
+ * Retrieves quick currency data for a specific currency in a given league and type.
5
+ * @param {string} league - The league for which to fetch currency data.
6
+ * @param {string} type - The type of currency data to fetch.
7
+ * @param {string} currencyTypeName - The currencyTypeName of the currency to fetch data for.
8
+ * @returns {Promise<{currencyTypeName: string, chaosEquivalent: number}>} An object containing the currency type name and its chaos equivalent.
9
+ * @throws {Error} Throws an error if the currency data cannot be fetched or if the currency is not found.
10
+ */
11
+ async function getQuickCurrency(league, type, currencyTypeName) {
12
+ try {
13
+ const fetchedData = await fetchCurrency(league, type);
14
+ for (const data of fetchedData) {
15
+ if (data.currencyTypeName === currencyTypeName) {
16
+ return {
17
+ currencyTypeName: data.currencyTypeName,
18
+ chaosEquivalent: data.chaosEquivalent,
19
+ };
20
+ }
21
+ }
22
+ throw new Error("Currency not found");
23
+ } catch (error) {
24
+ throw new Error(`Error fetching currency data: ${error.message}`);
25
+ }
26
+ }
27
+
28
+ module.exports = getQuickCurrency;
@@ -1,12 +1,6 @@
1
1
  const getData = require("./methods/getData");
2
2
 
3
3
  class ItemBaseClass {
4
- /**
5
- * @type {string} The URL used for retrieving item data.
6
- * @private
7
- */
8
- #url;
9
-
10
4
  /**
11
5
  * @type {string} The type of item to retrieve data for.
12
6
  * @private
@@ -14,36 +8,18 @@ class ItemBaseClass {
14
8
  #type;
15
9
 
16
10
  /**
17
- * @type {string} The base URL for poe.watch.
11
+ * @type {string} The name of the current league.
18
12
  * @private
19
13
  */
20
- #baseurl;
14
+ #league;
21
15
  /**
22
16
  * Constructs an instance of ItemBaseClass.
23
17
  * @param {string} league - The name of the league to retrieve data for.
24
18
  * @param {string} typeName - The type of item to retrieve data for.
25
19
  */
26
20
  constructor(league, typeName) {
27
- /**
28
- * The URL used for retrieving item data.
29
- * @type {string}
30
- * @private
31
- */
32
- this.#url = `${this.#baseurl}itemoverview?league=${league}`;
33
-
34
- /**
35
- * The type of item to retrieve data for.
36
- * @type {string}
37
- * @private
38
- */
39
- this.#type = `&type=${typeName}`;
40
-
41
- /**
42
- * The base URL for poe.watch.
43
- * @type {string}
44
- * @private
45
- */
46
- this.#baseurl = "https://poe.ninja/api/data/";
21
+ this.#type = typeName;
22
+ this.#league = league;
47
23
  }
48
24
 
49
25
  /**
@@ -54,7 +30,7 @@ class ItemBaseClass {
54
30
  */
55
31
  async getData(requestedProperties) {
56
32
  try {
57
- return await getData(this.#url, this.#type, requestedProperties);
33
+ return await getData(this.#league, this.#type, requestedProperties);
58
34
  } catch (error) {
59
35
  throw new Error(`Error fetching ItemOverView data: ${error.message}`);
60
36
  }
@@ -145,6 +145,11 @@ class ItemWievModule {
145
145
  * Represents a submodule for blight ravaged map item information.
146
146
  */
147
147
  this.blightRavagedMap = new itemSubmodules.BlightRavagedMapModule(league);
148
+
149
+ /**
150
+ * Represents a submodule for coffin item information.
151
+ */
152
+ this.coffin = new itemSubmodules.CoffinModule(league);
148
153
  }
149
154
  }
150
155
 
@@ -1,32 +1,27 @@
1
1
  const axios = require("axios");
2
+ const urlGenerator = require("../itemUrlGenerator/ItemUrlGenerator");
2
3
 
3
4
  /**
4
5
  * Asynchronously fetches data from a specified URL for item-related information.
5
6
  *
6
- * @param {string} baseurl - The base URL for the data fetch operation.
7
+ * @param {string} league - The league name for the data fetch operation.
7
8
  * @param {string} type - The specific type of item data to fetch.
8
9
  * @returns {Promise<Array<Object>>} - A promise that resolves to the fetched item data.
9
10
  * @throws {Error} - Throws an error if there's an issue fetching or processing the data.
10
11
  */
11
- async function fetchData(baseurl, type) {
12
+ async function fetchData(league, type) {
12
13
  try {
13
14
  /**
14
15
  * @type {string} url - The complete URL for fetching item-related data.
15
16
  */
16
- const url = `${baseurl}${type}`;
17
+ const url = urlGenerator(league, type);
17
18
 
18
- /**
19
- * @type {Object} response - The response object from the data fetch operation.
20
- */
21
19
  const response = await axios.get(url);
22
20
 
23
21
  if (response.data && response.data.lines) {
24
- /**
25
- * @type {Array<Object>} lines - The array of objects containing item-related data.
26
- */
27
22
  return response.data.lines;
28
23
  } else {
29
- throw new Error("Invalid response format from POE Ninja API Itemwiev");
24
+ throw new Error("Invalid response format from POE Ninja API ItemView");
30
25
  }
31
26
  } catch (error) {
32
27
  /**
@@ -27,4 +27,5 @@ module.exports = {
27
27
  ClusterJewelModule: require("./subModules/ClusterJewelModule"),
28
28
  BlightedMapModule: require("./subModules/BlightedMapModule"),
29
29
  BlightRavagedMapModule: require("./subModules/BlightRavagedMapModule"),
30
+ CoffinModule: require("./subModules/CoffinModule"),
30
31
  };
@@ -9,7 +9,12 @@ class BeastModule extends ItemBaseClass {
9
9
  * @param {string} league - The league name.
10
10
  */
11
11
  constructor(league) {
12
- super(league, "Beast");
12
+ /**
13
+ * The name of the beast type.
14
+ * @type {string}
15
+ */
16
+ const typeName = "Beast";
17
+ super(league, typeName);
13
18
  }
14
19
  }
15
20
 
@@ -0,0 +1,9 @@
1
+ const ItemBaseClass = require("../../ItemBaseClass");
2
+
3
+ class CoffinModule extends ItemBaseClass {
4
+ constructor(league, type = "Coffin") {
5
+ super(league, type);
6
+ }
7
+ }
8
+
9
+ module.exports = CoffinModule;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generates a URL based on league and type. poe.ninja (currencyView) API is used.
3
+ * @param {string} league - The league for which the URL is generated.
4
+ * @param {string} type - The type of data for which the URL is generated.
5
+ * @returns {string} - The generated URL.
6
+ */
7
+ module.exports = function urlGenerator(league, type) {
8
+ return `https://poe.ninja/api/data/itemoverview?league=${league}&type=${type}`;
9
+ };
@@ -4,25 +4,19 @@ const filterProperties = require("../../../mainfunctions/filter/propertyFilter")
4
4
  /**
5
5
  * Asynchronously fetches and filters item-related data from a specified URL.
6
6
  *
7
- * @param {string} url - The URL to fetch item-related data from.
7
+ * @param {string} league - The name of the current league.
8
8
  * @param {string} type - The type of item data to fetch.
9
9
  * @param {Array<string>} [requestedProperties] - (Optional) An array of property names to include in the filtered result.
10
10
  * @returns {Promise<Array<Object>|Object>} - A promise that resolves to the fetched or filtered item data.
11
11
  * @throws {Error} - Throws an error if there's an issue fetching or processing the data.
12
12
  */
13
- async function getData(url, type, requestedProperties) {
13
+ async function getData(league, type, requestedProperties) {
14
14
  try {
15
15
  // Fetch data using the fetchData function
16
- /**
17
- * @type {Array<Object>|Object} fetchedData - The fetched item data.
18
- */
19
- const fetchedData = await fetchData(url, type);
16
+ const fetchedData = await fetchData(league, type);
20
17
 
21
18
  // If requestedProperties are specified, filter the data based on those properties
22
19
  if (requestedProperties) {
23
- /**
24
- * @type {Array<Object>|Object} result - The filtered item data based on requested properties.
25
- */
26
20
  const result = filterProperties(fetchedData, requestedProperties);
27
21
  return result;
28
22
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-api-manager",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "API management for poe.ninja and poe.watch",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,7 +23,9 @@
23
23
  "poe economy api",
24
24
  "path of exile api",
25
25
  "poe.watch api",
26
- "poe.ninja api"
26
+ "poe.ninja api",
27
+ "backend",
28
+ "frontend"
27
29
  ],
28
30
  "author": "Ayberk Gezer",
29
31
  "license": "MIT",