@juice789/tf2items 1.0.0
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/README.md +3 -0
- package/api.js +59 -0
- package/app.js +42 -0
- package/blanket.js +119 -0
- package/fetchAppDataInventory.js +54 -0
- package/fetchItemsApi.js +33 -0
- package/fetchItemsGame.js +12 -0
- package/fetchParticleEffects.js +20 -0
- package/fetchTextures.js +21 -0
- package/fetchTfEnglish.js +13 -0
- package/fromEconItem.js +359 -0
- package/fromListingV1.js +374 -0
- package/fromListingV2.js +92 -0
- package/getCollections.js +34 -0
- package/getItems.js +42 -0
- package/options-example.json +3 -0
- package/package.json +37 -0
- package/sagaHelpers.js +9 -0
- package/sagas.js +13 -0
- package/saveSchema.js +42 -0
- package/schema.json +1 -0
- package/schemaHelper.json +958 -0
- package/schemaItems.js +15 -0
- package/sku.js +142 -0
- package/skuBp.js +87 -0
- package/toSearchParams.js +99 -0
- package/todo.txt +24 -0
- package/transformItems.js +106 -0
package/fromListingV2.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const {
|
|
2
|
+
compose,
|
|
3
|
+
propEq,
|
|
4
|
+
prop,
|
|
5
|
+
map,
|
|
6
|
+
__,
|
|
7
|
+
applyTo,
|
|
8
|
+
pathOr,
|
|
9
|
+
includes,
|
|
10
|
+
pathEq,
|
|
11
|
+
propOr,
|
|
12
|
+
ifElse,
|
|
13
|
+
equals,
|
|
14
|
+
length,
|
|
15
|
+
split,
|
|
16
|
+
allPass,
|
|
17
|
+
nth,
|
|
18
|
+
cond,
|
|
19
|
+
T,
|
|
20
|
+
F,
|
|
21
|
+
complement
|
|
22
|
+
} = require('ramda')
|
|
23
|
+
|
|
24
|
+
const { skuFromItem } = require('./sku.js')
|
|
25
|
+
const { remaps } = require('./fromListingV1.js')
|
|
26
|
+
|
|
27
|
+
const defindex = prop('defindex')
|
|
28
|
+
|
|
29
|
+
const quality = pathOr(null, ['quality', 'id'])
|
|
30
|
+
|
|
31
|
+
const uncraftable = compose(includes('Non-Craftable'), prop('name'))
|
|
32
|
+
|
|
33
|
+
const effect = pathOr(null, ['particle', 'id'])
|
|
34
|
+
|
|
35
|
+
const elevated = cond(
|
|
36
|
+
[
|
|
37
|
+
[compose(complement(equals)(11), quality), compose(equals(11), pathOr(null, ['elevatedQuality', 'id']))],
|
|
38
|
+
[compose(equals(11), quality), compose(includes(__, ['701', '702', '703', '704']), String, effect)],
|
|
39
|
+
[T, F]
|
|
40
|
+
]
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
const killstreakTier = propOr(null, 'killstreakTier')
|
|
44
|
+
|
|
45
|
+
const festivized = propEq('festivized', true)
|
|
46
|
+
|
|
47
|
+
const texture = pathOr(null, ['texture', 'id'])
|
|
48
|
+
|
|
49
|
+
const wear = pathOr(null, ['wearTier', 'id'])
|
|
50
|
+
|
|
51
|
+
const australium = propEq('australium', true)
|
|
52
|
+
|
|
53
|
+
const series = propOr(null, 'crateSeries')
|
|
54
|
+
|
|
55
|
+
const target = ifElse(
|
|
56
|
+
allPass([
|
|
57
|
+
pathEq(['recipe', 'targetItem'], null),
|
|
58
|
+
compose(equals(3), length, split('-'), prop('priceindex'))
|
|
59
|
+
]),
|
|
60
|
+
compose(nth(2), split('-'), prop('priceindex')),
|
|
61
|
+
pathOr(null, ['recipe', 'targetItem', '_source', 'defindex'])
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
const output = pathOr(null, ['recipe', 'outputItem', 'defindex'])
|
|
65
|
+
|
|
66
|
+
const oq = pathOr(null, ['recipe', 'outputItem', 'quality', 'id'])
|
|
67
|
+
|
|
68
|
+
const fns = {
|
|
69
|
+
defindex,
|
|
70
|
+
quality,
|
|
71
|
+
uncraftable,
|
|
72
|
+
elevated,
|
|
73
|
+
effect,
|
|
74
|
+
killstreakTier,
|
|
75
|
+
festivized,
|
|
76
|
+
texture,
|
|
77
|
+
wear,
|
|
78
|
+
australium,
|
|
79
|
+
series,
|
|
80
|
+
target,
|
|
81
|
+
output,
|
|
82
|
+
oq
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const fromListingV2 = compose(
|
|
86
|
+
skuFromItem,
|
|
87
|
+
remaps,
|
|
88
|
+
map(__, fns),
|
|
89
|
+
applyTo
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
module.exports = { fromListingV2 }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const { prop, map, compose, toLower, mapObjIndexed, toPairs, when, has, __, chain, assoc, reduce, mergeRight, values, path, uncurryN, replace } = require('ramda')
|
|
2
|
+
const { renameKeysWith } = require('ramda-adjunct')
|
|
3
|
+
|
|
4
|
+
const simplifyCollections = compose(
|
|
5
|
+
reduce((curr, obj) => mergeRight(curr, obj), {}),
|
|
6
|
+
values,
|
|
7
|
+
mapObjIndexed(
|
|
8
|
+
(collection, key) => map(assoc('collection', key), collection)
|
|
9
|
+
),
|
|
10
|
+
map(
|
|
11
|
+
compose(
|
|
12
|
+
reduce((curr, obj) => mergeRight(curr, obj), {}),
|
|
13
|
+
map(([rarity, items]) => map(() => ({ rarity }), items)),
|
|
14
|
+
toPairs,
|
|
15
|
+
prop('items')
|
|
16
|
+
)
|
|
17
|
+
),
|
|
18
|
+
(collections) => renameKeysWith((key) => replace('#', '', path([key, 'name'], collections)), collections),
|
|
19
|
+
prop('item_collections')
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
const localizeCollections = uncurryN(2, (english) => map(
|
|
23
|
+
when(
|
|
24
|
+
compose(has(__, english), compose(toLower, prop('collection'))),
|
|
25
|
+
chain(assoc('collection'), compose(prop(__, english), toLower, prop('collection')))
|
|
26
|
+
)
|
|
27
|
+
))
|
|
28
|
+
|
|
29
|
+
const getCollections = uncurryN(2, (english) => compose(
|
|
30
|
+
localizeCollections(english),
|
|
31
|
+
simplifyCollections
|
|
32
|
+
))
|
|
33
|
+
|
|
34
|
+
module.exports = { getCollections }
|
package/getItems.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { prop, map, compose, toLower, when, has, __, chain, assoc, reduce, omit, props, split, propOr, replace, mergeDeepLeft, mergeDeepWith } = require('ramda')
|
|
2
|
+
|
|
3
|
+
function getItems(english, items_game) {
|
|
4
|
+
|
|
5
|
+
var mergePrefab = (item) => mergeDeepLeft(
|
|
6
|
+
omit(['prefab'], item),
|
|
7
|
+
reduce(
|
|
8
|
+
mergeDeepWith((p, n) => p + ' ' + n),
|
|
9
|
+
{},
|
|
10
|
+
props(split(' ', item.prefab), items_game.prefabs)
|
|
11
|
+
)
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
var mergePrefabs = when(
|
|
15
|
+
has('prefab'),
|
|
16
|
+
(a) => mergePrefabs(mergePrefab(a))
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
var localize = (key) => chain(
|
|
20
|
+
assoc(key),
|
|
21
|
+
compose(
|
|
22
|
+
prop(__, english),
|
|
23
|
+
replace('#', ''),
|
|
24
|
+
toLower,
|
|
25
|
+
propOr('NaN', key)
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const items = map(
|
|
30
|
+
compose(
|
|
31
|
+
localize('item_type_name'),
|
|
32
|
+
localize('item_name'),
|
|
33
|
+
mergePrefabs
|
|
34
|
+
),
|
|
35
|
+
items_game.items
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
return items
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = { getItems }
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@juice789/tf2items",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "tf2 item schema thingys",
|
|
5
|
+
"main": "app.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"tf2",
|
|
11
|
+
"sku"
|
|
12
|
+
],
|
|
13
|
+
"author": "juice789",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/juice789/tf2items"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/juice789/tf2items/issues"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"axios": "^0.27.2",
|
|
24
|
+
"ramda": "^0.28.0",
|
|
25
|
+
"ramda-adjunct": "^3.2.0",
|
|
26
|
+
"redux-saga": "^1.1.3",
|
|
27
|
+
"vdf": "^0.0.2"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"jest": "^28.1.3",
|
|
31
|
+
"redux-saga-test-plan": "^4.0.5"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"sideEffects": false
|
|
37
|
+
}
|
package/sagaHelpers.js
ADDED
package/sagas.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
fetchItemsApiSaga,
|
|
9
|
+
fetchItemsGameSaga,
|
|
10
|
+
fetchParticleEffectsSaga,
|
|
11
|
+
fetchTexturesSaga,
|
|
12
|
+
fetchTfEnglishSaga
|
|
13
|
+
}
|
package/saveSchema.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { call } = require('redux-saga/effects')
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
fetchItemsApiSaga,
|
|
5
|
+
fetchItemsGameSaga,
|
|
6
|
+
fetchParticleEffectsSaga,
|
|
7
|
+
fetchTexturesSaga,
|
|
8
|
+
fetchTfEnglishSaga
|
|
9
|
+
} = require('./sagas.js')
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
getCollections,
|
|
13
|
+
getItems,
|
|
14
|
+
transformItems
|
|
15
|
+
} = require('./sagaHelpers')
|
|
16
|
+
|
|
17
|
+
function* saveSchemaSaga() {
|
|
18
|
+
try {
|
|
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)
|
|
25
|
+
|
|
26
|
+
const collections = getCollections(english, itemsGame)
|
|
27
|
+
const items = getItems(english, itemsGame)
|
|
28
|
+
const transformedItems = transformItems(collections, itemsApi, items)
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
particleEffects,
|
|
32
|
+
textures,
|
|
33
|
+
collections,
|
|
34
|
+
items: transformedItems
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
} catch (err) {
|
|
38
|
+
console.log('error saving schema', err)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = { saveSchemaSaga }
|