diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index eb66bae..8a40f2e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,7 +17,7 @@ jobs: node-version-file: .nvmrc - run: | npm ci --omit=optional - npm install --no-save warframe-worldstate-parser@^3.x warframe-worldstate-data@^2.x + npm install --no-save warframe-worldstate-parser@^4.x warframe-worldstate-data@^2.x - uses: actions/cache/save@v4 with: path: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d06c548..b8cdd59 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -21,7 +21,7 @@ jobs: - name: Verify run: | npm ci --omit=optional - npm install --no-save warframe-worldstate-parser@^3.x warframe-worldstate-data@^2.x + npm install --no-save warframe-worldstate-parser@^4.x warframe-worldstate-data@^2.x npm run lint npx commitlint --from=HEAD~1 npm test diff --git a/.gitignore b/.gitignore index 575ac12..5f06004 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules .jshintignore .jshintrc +.eslintcache diff --git a/package-lock.json b/package-lock.json index 4c6e3c9..d4af197 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2,7 +2,6 @@ "name": "worldstate-emitter", "version": "0.0.0-dev", "lockfileVersion": 3, - "requires": true, "packages": { "": { "name": "worldstate-emitter", @@ -36,7 +35,7 @@ }, "peerDependencies": { "warframe-worldstate-data": "^2.x", - "warframe-worldstate-parser": "^3.x" + "warframe-worldstate-parser": "^4.x" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -1947,15 +1946,15 @@ } }, "node_modules/@commitlint/config-validator/node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.16.0.tgz", + "integrity": "sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==", "dev": true, "dependencies": { - "fast-deep-equal": "^3.1.1", + "fast-deep-equal": "^3.1.3", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" + "uri-js": "^4.4.1" }, "funding": { "type": "github", @@ -2032,26 +2031,11 @@ "node": ">=v18" } }, - "node_modules/@commitlint/is-ignored/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@commitlint/is-ignored/node_modules/semver": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", - "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, "bin": { "semver": "bin/semver.js" }, @@ -2059,12 +2043,6 @@ "node": ">=10" } }, - "node_modules/@commitlint/is-ignored/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/@commitlint/lint": { "version": "19.2.2", "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-19.2.2.tgz", @@ -2451,19 +2429,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/@eslint/eslintrc/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true, - "peer": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@eslint/js": { "version": "8.56.0", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", @@ -5115,19 +5080,6 @@ "node": ">=8" } }, - "node_modules/eslint/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true, - "peer": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/espree": { "version": "9.6.1", "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", @@ -5299,9 +5251,9 @@ } }, "node_modules/ext/node_modules/type": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", - "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==", + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.3.tgz", + "integrity": "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ==", "dev": true }, "node_modules/extend": { @@ -7254,26 +7206,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/make-dir/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/make-dir/node_modules/semver": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", - "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, "bin": { "semver": "bin/semver.js" }, @@ -7281,12 +7218,6 @@ "node": ">=10" } }, - "node_modules/make-dir/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/memoizee": { "version": "0.4.15", "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", @@ -7638,26 +7569,11 @@ "url": "https://opencollective.com/nodemon" } }, - "node_modules/nodemon/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/nodemon/node_modules/semver": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", - "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, "bin": { "semver": "bin/semver.js" }, @@ -7665,12 +7581,6 @@ "node": ">=10" } }, - "node_modules/nodemon/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/nopt": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", @@ -8736,26 +8646,11 @@ "node": ">=10" } }, - "node_modules/simple-update-notifier/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/simple-update-notifier/node_modules/semver": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", - "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, "bin": { "semver": "bin/semver.js" }, @@ -8763,12 +8658,6 @@ "node": ">=10" } }, - "node_modules/simple-update-notifier/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -9351,6 +9240,19 @@ "node": ">=4" } }, + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "peer": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/typed-array-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.2.tgz", @@ -9609,9 +9511,9 @@ } }, "node_modules/warframe-worldstate-parser": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/warframe-worldstate-parser/-/warframe-worldstate-parser-3.0.2.tgz", - "integrity": "sha512-y4L0yN15XFViDpwCwlI4i4htkf6OteazN7QqOXgjjImzHXmnM+jWpXj526Ei/f5iK/MKeiN/KrSmsQifKgSk1w==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/warframe-worldstate-parser/-/warframe-worldstate-parser-4.0.1.tgz", + "integrity": "sha512-DVIDceKOl+XiQpz/x+51THFRX+nV8j/7CyJVBP+xiSGvasbwXa0Ym+elJuY4ziNYHzrm3PrWLBTuvCECzYXQJg==", "peer": true, "engines": { "node": ">=18.19.0" @@ -9973,5 +9875,6 @@ "url": "https://github.com/sponsors/sindresorhus" } } - } + }, + "requires": true } diff --git a/package.json b/package.json index 1f5f0f4..2e05b4c 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,9 @@ "@commitlint/config-conventional" ], "rules": { - "body-max-line-length": [0] + "body-max-line-length": [ + 0 + ] } }, "lint-staged": { @@ -131,7 +133,7 @@ }, "peerDependencies": { "warframe-worldstate-data": "^2.x", - "warframe-worldstate-parser": "^3.x" + "warframe-worldstate-parser": "^4.x" }, "optionalDependencies": { "colors": "^1.4.0", diff --git a/test/specs/access.spec.js b/test/specs/access.spec.js index 58d8651..1bd8f26 100644 --- a/test/specs/access.spec.js +++ b/test/specs/access.spec.js @@ -3,6 +3,7 @@ import chai from 'chai'; import WSEmitter from '../../index.js'; chai.should(); +const { expect } = chai; const ws = await WSEmitter.make(); @@ -12,6 +13,7 @@ describe('access', function () { }); it('should return data when requested', async () => { const data = ws.getWorldstate(); + data.should.be .an('object') .that.has.all.keys( @@ -48,5 +50,7 @@ describe('access', function () { 'weeklyChallenges', 'zarimanCycle' ); + + data.syndicateMissions.some((mission) => mission.jobs.some((job) => expect(job).to.not.be.empty)).should.be.true; }); }); diff --git a/utilities/WSCache.js b/utilities/WSCache.js index 8d2da30..26ca74f 100644 --- a/utilities/WSCache.js +++ b/utilities/WSCache.js @@ -1,4 +1,4 @@ -import Worldstate from 'warframe-worldstate-parser'; +import WorldState from 'warframe-worldstate-parser'; import { logger } from './index.js'; @@ -16,7 +16,7 @@ export default class WSCache { /** * Set up a cache checking for data and updates to a specific worldstate set - * @param {string} language Langauge/translation to track + * @param {string} language Language/translation to track * @param {Cache} kuvaCache Cache of kuva data, provided by Semlar * @param {Cache} sentientCache Cache of sentient outpost data, provided by Semlar * @param {EventEmitter} eventEmitter Emitter to push new worldstate updates to @@ -29,6 +29,27 @@ export default class WSCache { this.#emitter = eventEmitter; } + /** + * Update the current data with new data + * @param {string} newData updated worldstate data + * @returns {Promise} + */ + #update = async (newData) => { + const t = await WorldState.build(newData, { + locale: this.#language, + kuvaData: JSON.parse(await this.#kuvaCache.get()), + sentientData: JSON.parse(await this.#sentientCache.get()), + }); + if (!t.timestamp) return; + + this.#inner = t; + this.#emitter.emit('ws:update:parsed', { + language: this.#language, + platform: this.#platform, + data: t, + }); + }; + /** * Get the latest worldstate data from this cache * @returns {Object} Current worldstate data @@ -43,21 +64,7 @@ export default class WSCache { */ set data(newData) { logger.debug(`got new data for ${this.#language}, parsing...`); - setTimeout(async () => { - const t = new Worldstate(newData, { - locale: this.#language, - kuvaData: JSON.parse(await this.#kuvaCache.get()), - sentientData: JSON.parse(await this.#sentientCache.get()), - }); - if (!t.timestamp) return; - - this.#inner = t; - this.#emitter.emit('ws:update:parsed', { - language: this.#language, - platform: this.#platform, - data: t, - }); - }, 0); + this.#update(newData); } /**