@juice789/tf2items 1.0.15 → 1.0.17

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/app.js CHANGED
@@ -1,6 +1,5 @@
1
1
  const { runSaga } = require('redux-saga')
2
- const { map, compose, replace } = require('ramda')
3
- const { renameKeysWith } = require('ramda-adjunct')
2
+ const { map } = require('ramda')
4
3
 
5
4
  const helperObjects = require('./schemaHelper.json')
6
5
  const sagaHelpers = require('./sagaHelpers')
@@ -13,7 +12,7 @@ const skuLinks = require('./skuLinks.js')
13
12
  const { createApi, api } = require('./api.js')
14
13
 
15
14
  const sagas = require('./sagas.js')
16
- const { saveSchemaSaga } = require('./saveSchema.js')
15
+ const { saveSchema } = require('./saveSchema.js')
17
16
 
18
17
  const { fromEconItem } = require('./fromEconItem.js')
19
18
  const { fromListingV1 } = require('./fromListingV1.js')
@@ -23,18 +22,18 @@ const { toSearchParams } = require('./toSearchParams.js')
23
22
 
24
23
  const getInstance = (options) => {
25
24
  const api = createApi(options)
26
- return compose(
27
- renameKeysWith(replace('Saga', '')),
28
- map(
25
+ const fns = { ...sagas, saveSchema }
26
+ return options.saga
27
+ ? fns
28
+ : map(
29
29
  (saga) => (...args) => new Promise((resolve, reject) => {
30
30
  runSaga({
31
31
  context: { api }
32
32
  }, saga, ...args)
33
33
  .toPromise()
34
34
  .then(resolve, reject)
35
- })
36
- ),
37
- )({ ...sagas, saveSchemaSaga })
35
+ }), fns
36
+ )
38
37
  }
39
38
 
40
39
  module.exports = {
@@ -45,7 +44,7 @@ module.exports = {
45
44
  ...sagas,
46
45
  ...sagaHelpers,
47
46
  ...skuLinks,
48
- saveSchemaSaga,
47
+ saveSchema,
49
48
  getInstance,
50
49
  createApi,
51
50
  api,
@@ -32,7 +32,7 @@ const mergeAssetClasses = uncurryN(2, (assetClasses) => compose(
32
32
  groupBy(props(['classid', 'instanceid']))
33
33
  ))
34
34
 
35
- function* fetchAppDataInventorySaga(inventory, d = 1000) {
35
+ function* fetchAppDataInventory(inventory, d = 1000) {
36
36
 
37
37
  let p = 0, assetClasses = {}
38
38
  const { getAssetClassInfo } = yield getContext('api')
@@ -50,5 +50,5 @@ function* fetchAppDataInventorySaga(inventory, d = 1000) {
50
50
  }
51
51
 
52
52
  module.exports = {
53
- fetchAppDataInventorySaga
53
+ fetchAppDataInventory
54
54
  }
package/fetchItemsApi.js CHANGED
@@ -17,7 +17,7 @@ const transformItemsApi = compose(
17
17
  indexBy(prop('defindex'))
18
18
  )
19
19
 
20
- function* fetchItemsApiSaga() {
20
+ function* fetchItemsApi() {
21
21
  const { getSchemaItems } = yield getContext('api')
22
22
  let start = 0, items = []
23
23
  do {
@@ -30,4 +30,4 @@ function* fetchItemsApiSaga() {
30
30
  }
31
31
 
32
32
 
33
- module.exports = { fetchItemsApiSaga }
33
+ module.exports = { fetchItemsApi }
package/fetchItemsGame.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const { call, getContext } = require('redux-saga/effects')
2
2
  const vdf = require('vdf')
3
3
 
4
- function* fetchItemsGameSaga() {
4
+ function* fetchItemsGame() {
5
5
  const { getItemsGameUrl, getItemsGame } = yield getContext('api')
6
6
  const { result: { items_game_url } } = yield call(getItemsGameUrl)
7
7
  const itemsGameVdf = yield call(getItemsGame, items_game_url)
@@ -9,4 +9,4 @@ function* fetchItemsGameSaga() {
9
9
  return items_game
10
10
  }
11
11
 
12
- module.exports = { fetchItemsGameSaga }
12
+ module.exports = { fetchItemsGame }
@@ -11,10 +11,10 @@ const transformEffects = compose(
11
11
  path(['result', 'attribute_controlled_attached_particles'])
12
12
  )
13
13
 
14
- function* fetchParticleEffectsSaga() {
14
+ function* fetchParticleEffects() {
15
15
  const { getSchemaOverview } = yield getContext('api')
16
16
  const schema = yield call(getSchemaOverview)
17
17
  return transformEffects(schema)
18
18
  }
19
19
 
20
- module.exports = { fetchParticleEffectsSaga }
20
+ module.exports = { fetchParticleEffects }
package/fetchTextures.js CHANGED
@@ -12,10 +12,10 @@ const transformTextures = compose(
12
12
  path(['lang', 'Tokens'])
13
13
  )
14
14
 
15
- function* fetchTexturesSaga() {
15
+ function* fetchTextures() {
16
16
  const { fetchProtoObjDefs } = yield getContext('api')
17
17
  const protoObjDefs = yield call(fetchProtoObjDefs)
18
18
  return transformTextures(vdf.parse(protoObjDefs))
19
19
  }
20
20
 
21
- module.exports = { fetchTexturesSaga }
21
+ module.exports = { fetchTextures }
package/fetchTfEnglish.js CHANGED
@@ -3,11 +3,11 @@ const vdf = require('vdf')
3
3
  const { toLower } = require('ramda')
4
4
  const { renameKeysWith } = require('ramda-adjunct')
5
5
 
6
- function* fetchTfEnglishSaga() {
6
+ function* fetchTfEnglish() {
7
7
  const { fetchTfEnglish } = yield getContext('api')
8
8
  const english = yield call(fetchTfEnglish)
9
9
  const englishVdf = vdf.parse(english)
10
10
  return renameKeysWith(toLower, englishVdf.lang.Tokens)
11
11
  }
12
12
 
13
- module.exports = { fetchTfEnglishSaga }
13
+ module.exports = { fetchTfEnglish }
package/fromEconItem.js CHANGED
@@ -36,7 +36,8 @@ const {
36
36
  of,
37
37
  path,
38
38
  equals,
39
- pick
39
+ pick,
40
+ assocPath
40
41
  } = require('ramda')
41
42
 
42
43
  const { safeItems: items } = require('./schemaItems.js')
@@ -187,8 +188,15 @@ const uncraftable = compose(
187
188
 
188
189
  const market_hash_name = prop('market_hash_name')
189
190
 
190
- const quality = pathOr('-1', ['app_data', 'quality'])
191
+ const setQuality = when(
192
+ compose(complement(Boolean), path(['app_data', 'quality'])),
193
+ chain(
194
+ assocPath(['app_data', 'quality']),
195
+ compose(prop(__, invertObj(qualityNames)), findTag('Quality'))
196
+ )
197
+ )
191
198
 
199
+ const quality = pathOr('-1', ['app_data', 'quality'])
192
200
  const defindex = pathOr('-1', ['app_data', 'def_index'])
193
201
 
194
202
  const propsTf2_1 = {
@@ -339,7 +347,8 @@ const fromEconItem440 = compose(
339
347
  remaps,
340
348
  chain(mergeRight, compose(map(__, propsTf2_2), applyTo)),
341
349
  map(__, propsTf2_1),
342
- unary(applyTo)
350
+ unary(applyTo),
351
+ setQuality
343
352
  )
344
353
 
345
354
  const fromEconItemOther = compose(
@@ -1,3 +1,4 @@
1
1
  {
2
- "steamApiKey": ""
2
+ "steamApiKey": "",
3
+ "saga": false
3
4
  }
package/options.json CHANGED
@@ -1 +1,4 @@
1
- {"steamApiKey": "1E55C647593C029A0C9BE22F97F03F03"}
1
+ {
2
+ "steamApiKey": "1E55C647593C029A0C9BE22F97F03F03",
3
+ "saga": false
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juice789/tf2items",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "tf2 item schema thingys",
5
5
  "main": "app.js",
6
6
  "scripts": {
package/sagas.js CHANGED
@@ -1,15 +1,15 @@
1
- const { fetchItemsApiSaga } = require('./fetchItemsApi.js')
2
- const { fetchItemsGameSaga } = require('./fetchItemsGame.js')
3
- const { fetchParticleEffectsSaga } = require('./fetchParticleEffects.js')
4
- const { fetchTexturesSaga } = require('./fetchTextures.js')
5
- const { fetchTfEnglishSaga } = require('./fetchTfEnglish.js')
6
- const { fetchAppDataInventorySaga } = require('./fetchAppDataInventory.js')
1
+ const { fetchItemsApi } = require('./fetchItemsApi.js')
2
+ const { fetchItemsGame } = require('./fetchItemsGame.js')
3
+ const { fetchParticleEffects } = require('./fetchParticleEffects.js')
4
+ const { fetchTextures } = require('./fetchTextures.js')
5
+ const { fetchTfEnglish } = require('./fetchTfEnglish.js')
6
+ const { fetchAppDataInventory } = require('./fetchAppDataInventory.js')
7
7
 
8
8
  module.exports = {
9
- fetchItemsApiSaga,
10
- fetchItemsGameSaga,
11
- fetchParticleEffectsSaga,
12
- fetchTexturesSaga,
13
- fetchTfEnglishSaga,
14
- fetchAppDataInventorySaga
9
+ fetchItemsApi,
10
+ fetchItemsGame,
11
+ fetchParticleEffects,
12
+ fetchTextures,
13
+ fetchTfEnglish,
14
+ fetchAppDataInventory
15
15
  }
package/saveSchema.js CHANGED
@@ -1,11 +1,11 @@
1
1
  const { call } = require('redux-saga/effects')
2
2
 
3
3
  const {
4
- fetchItemsApiSaga,
5
- fetchItemsGameSaga,
6
- fetchParticleEffectsSaga,
7
- fetchTexturesSaga,
8
- fetchTfEnglishSaga
4
+ fetchItemsApi,
5
+ fetchItemsGame,
6
+ fetchParticleEffects,
7
+ fetchTextures,
8
+ fetchTfEnglish
9
9
  } = require('./sagas.js')
10
10
 
11
11
  const {
@@ -14,14 +14,14 @@ const {
14
14
  transformItems
15
15
  } = require('./sagaHelpers')
16
16
 
17
- function* saveSchemaSaga() {
17
+ function* saveSchema() {
18
18
  try {
19
19
 
20
- const itemsApi = yield call(fetchItemsApiSaga)
21
- const itemsGame = yield call(fetchItemsGameSaga)
22
- const particleEffects = yield call(fetchParticleEffectsSaga)
23
- const textures = yield call(fetchTexturesSaga)
24
- const english = yield call(fetchTfEnglishSaga)
20
+ const itemsApi = yield call(fetchItemsApi)
21
+ const itemsGame = yield call(fetchItemsGame)
22
+ const particleEffects = yield call(fetchParticleEffects)
23
+ const textures = yield call(fetchTextures)
24
+ const english = yield call(fetchTfEnglish)
25
25
 
26
26
  const collections = getCollections(english, itemsGame)
27
27
  const items = getItems(english, itemsGame)
@@ -39,4 +39,4 @@ function* saveSchemaSaga() {
39
39
  }
40
40
  }
41
41
 
42
- module.exports = { saveSchemaSaga }
42
+ module.exports = { saveSchema }