@juice789/tf2items 1.0.31 → 1.0.33
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/blanket.js +2 -2
- package/fetchTextures.js +2 -3
- package/fetchTfEnglish.js +2 -3
- package/fromEconItem.js +45 -21
- package/getCollections.js +2 -3
- package/package.json +7 -10
- package/schema.json +1 -1
- package/sku753.js +28 -0
package/blanket.js
CHANGED
|
@@ -24,9 +24,9 @@ const {
|
|
|
24
24
|
concat,
|
|
25
25
|
unnest,
|
|
26
26
|
pick,
|
|
27
|
-
mergeRight
|
|
27
|
+
mergeRight,
|
|
28
|
+
renameKeys
|
|
28
29
|
} = require('ramda')
|
|
29
|
-
const { renameKeys } = require('ramda-adjunct')
|
|
30
30
|
|
|
31
31
|
const { safeItems: items } = require('./schemaItems.js')
|
|
32
32
|
const { skuFromItem, itemFromSku } = require('./sku.js')
|
package/fetchTextures.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const { call, getContext } = require('redux-saga/effects')
|
|
2
2
|
const vdf = require('vdf')
|
|
3
3
|
|
|
4
|
-
const { path, compose, pickBy, startsWith, reduce, replace, __ } = require('ramda')
|
|
5
|
-
const { renameKeysWith } = require('ramda-adjunct')
|
|
4
|
+
const { path, compose, pickBy, startsWith, reduce, replace, __, mapKeys } = require('ramda')
|
|
6
5
|
|
|
7
6
|
const sanitizeTexture = reduce((all, curr) => replace(curr, '', all), __, ['9_', '_field { field_number: 2 }'])
|
|
8
7
|
|
|
9
8
|
const transformTextures = compose(
|
|
10
|
-
|
|
9
|
+
mapKeys(sanitizeTexture),
|
|
11
10
|
pickBy((val, key) => startsWith('9', key) && isNaN(val[0])),
|
|
12
11
|
path(['lang', 'Tokens'])
|
|
13
12
|
)
|
package/fetchTfEnglish.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const { call, getContext } = require('redux-saga/effects')
|
|
2
2
|
const vdf = require('vdf')
|
|
3
|
-
const { toLower } = require('ramda')
|
|
4
|
-
const { renameKeysWith } = require('ramda-adjunct')
|
|
3
|
+
const { toLower, mapKeys } = require('ramda')
|
|
5
4
|
|
|
6
5
|
function* fetchTfEnglish() {
|
|
7
6
|
const { fetchTfEnglish } = yield getContext('api')
|
|
8
7
|
const english = yield call(fetchTfEnglish)
|
|
9
8
|
const englishVdf = vdf.parse(english)
|
|
10
|
-
return
|
|
9
|
+
return mapKeys(toLower, englishVdf.lang.Tokens)
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
module.exports = { fetchTfEnglish }
|
package/fromEconItem.js
CHANGED
|
@@ -40,14 +40,17 @@ const {
|
|
|
40
40
|
isEmpty,
|
|
41
41
|
join,
|
|
42
42
|
filter,
|
|
43
|
-
omit
|
|
43
|
+
omit,
|
|
44
|
+
last,
|
|
45
|
+
defaultTo,
|
|
46
|
+
renameKeys
|
|
44
47
|
} = require('ramda')
|
|
45
48
|
|
|
46
49
|
const { safeItems: items } = require('./schemaItems.js')
|
|
47
50
|
const { particleEffects, textures } = require('./schema.json')
|
|
48
51
|
const { qualityNames, wears, paintDefindex, spellDefindex } = require('./schemaHelper.json')
|
|
49
52
|
const { skuFromItem } = require('./sku.js')
|
|
50
|
-
const {
|
|
53
|
+
const { skuFromItem753 } = require('./sku753.js')
|
|
51
54
|
|
|
52
55
|
const marketHashIncludes = curry((string, { market_hash_name }) => market_hash_name.indexOf(string) !== -1)
|
|
53
56
|
|
|
@@ -57,8 +60,8 @@ const removeStrings = curry((string, strings) => compose(
|
|
|
57
60
|
reduce((all, curr) => replace(curr, '', all), string || '')
|
|
58
61
|
)(strings))
|
|
59
62
|
|
|
60
|
-
const findTag = uncurryN(
|
|
61
|
-
prop(
|
|
63
|
+
const findTag = uncurryN(3, (tagName, displayProp) => compose(
|
|
64
|
+
prop(displayProp),
|
|
62
65
|
find(propEq(tagName, 'category_name')),
|
|
63
66
|
map(renameKeys({
|
|
64
67
|
localized_category_name: 'category_name',
|
|
@@ -69,7 +72,11 @@ const findTag = uncurryN(2, (tagName) => compose(
|
|
|
69
72
|
|
|
70
73
|
const old_id = ({ new_assetid, rollback_new_assetid, assetid }) => (new_assetid || rollback_new_assetid) ? assetid : null
|
|
71
74
|
|
|
72
|
-
const id = ({ new_assetid, rollback_new_assetid, assetid }) => new_assetid || rollback_new_assetid || assetid
|
|
75
|
+
const id = ({ new_assetid, rollback_new_assetid, assetid }) => new_assetid || rollback_new_assetid || assetid || null
|
|
76
|
+
|
|
77
|
+
const old_contextid = ({ new_contextid, rollback_new_contextid, contextid }) => (new_contextid || rollback_new_contextid) ? contextid : null
|
|
78
|
+
|
|
79
|
+
const contextid = ({ new_contextid, rollback_new_contextid, contextid }) => new_contextid || rollback_new_contextid || contextid || null
|
|
73
80
|
|
|
74
81
|
const recipe = compose(
|
|
75
82
|
find(__, ['Fabricator', 'Strangifier Chemistry Set', 'Chemistry Set']),
|
|
@@ -77,7 +84,7 @@ const recipe = compose(
|
|
|
77
84
|
)
|
|
78
85
|
|
|
79
86
|
const series = ifElse(
|
|
80
|
-
compose(equals('Crate'), findTag('Type')),
|
|
87
|
+
compose(equals('Crate'), findTag('Type', 'name')),
|
|
81
88
|
ifElse(
|
|
82
89
|
marketHashIncludes('#'),
|
|
83
90
|
compose(
|
|
@@ -116,11 +123,11 @@ const australium = allPass([
|
|
|
116
123
|
const wear = compose(
|
|
117
124
|
prop(__, invertObj(wears)),
|
|
118
125
|
removeStrings(__, ['(', ')']),
|
|
119
|
-
findTag('Exterior')
|
|
126
|
+
findTag('Exterior', 'name')
|
|
120
127
|
)
|
|
121
128
|
|
|
122
129
|
const texture = ifElse(
|
|
123
|
-
findTag('Exterior'),
|
|
130
|
+
findTag('Exterior', 'name'),
|
|
124
131
|
compose(
|
|
125
132
|
propOr('-1', __, invertObj(textures)),
|
|
126
133
|
({ app_data, market_hash_name }) => removeStrings(market_hash_name, [
|
|
@@ -205,7 +212,7 @@ const setQuality = when(
|
|
|
205
212
|
compose(complement(Boolean), path(['app_data', 'quality'])),
|
|
206
213
|
chain(
|
|
207
214
|
assocPath(['app_data', 'quality']),
|
|
208
|
-
compose(prop(__, invertObj(qualityNames)), findTag('Quality'))
|
|
215
|
+
compose(prop(__, invertObj(qualityNames)), findTag('Quality', 'name'))
|
|
209
216
|
)
|
|
210
217
|
)
|
|
211
218
|
|
|
@@ -230,7 +237,9 @@ const propsTf2_1 = {
|
|
|
230
237
|
halloweenSpell,
|
|
231
238
|
paintColor,
|
|
232
239
|
id,
|
|
233
|
-
old_id
|
|
240
|
+
old_id,
|
|
241
|
+
contextid,
|
|
242
|
+
old_contextid
|
|
234
243
|
}
|
|
235
244
|
|
|
236
245
|
const isTarget = either(
|
|
@@ -315,6 +324,17 @@ const propsOtherGame = {
|
|
|
315
324
|
old_id
|
|
316
325
|
}
|
|
317
326
|
|
|
327
|
+
const props753 = {
|
|
328
|
+
market_hash_name: prop('market_hash_name'),
|
|
329
|
+
border: compose(last, defaultTo(''), findTag('Card Border', 'internal_name')),
|
|
330
|
+
game: compose(nth(1), split('_'), findTag('Game', 'internal_name')),
|
|
331
|
+
type: compose(last, findTag('Item Type', 'internal_name')),
|
|
332
|
+
id,
|
|
333
|
+
old_id,
|
|
334
|
+
contextid,
|
|
335
|
+
old_contextid
|
|
336
|
+
}
|
|
337
|
+
|
|
318
338
|
const keyRemap = when(
|
|
319
339
|
compose(
|
|
320
340
|
includes(__, ['5021', '5049', '5067', '5072', '5073', '5079', '5081', '5628', '5631', '5632', '5713', '5716', '5717', '5762', '5791', '5792']), //old keys that turned into regular keys
|
|
@@ -362,7 +382,7 @@ const defaultOptions440 = {
|
|
|
362
382
|
}
|
|
363
383
|
|
|
364
384
|
const fromEconItem440 = ({ omitProps = [], uncraftRemapDefindex = [] } = defaultOptions440) => compose(
|
|
365
|
-
pick(['sku', 'id', 'old_id']),
|
|
385
|
+
pick(['sku', 'id', 'old_id', 'contextid', 'old_contextid']),
|
|
366
386
|
chain(assoc('sku'), skuFromItem),
|
|
367
387
|
uncraftRemap(uncraftRemapDefindex),
|
|
368
388
|
kitRemap,
|
|
@@ -374,22 +394,26 @@ const fromEconItem440 = ({ omitProps = [], uncraftRemapDefindex = [] } = default
|
|
|
374
394
|
setQuality
|
|
375
395
|
)
|
|
376
396
|
|
|
397
|
+
const fromEconItem753 = () => compose(
|
|
398
|
+
pick(['sku', 'id', 'old_id', 'contextid', 'old_contextid']),
|
|
399
|
+
chain(assoc('sku'), skuFromItem753),
|
|
400
|
+
map(__, props753),
|
|
401
|
+
unary(applyTo)
|
|
402
|
+
)
|
|
403
|
+
|
|
377
404
|
const fromEconItemOther = (options = {}) => compose(
|
|
378
405
|
map(__, propsOtherGame),
|
|
379
406
|
unary(applyTo)
|
|
380
407
|
)
|
|
381
408
|
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
409
|
+
const mainFns = {
|
|
410
|
+
440: fromEconItem440,
|
|
411
|
+
753: fromEconItem753
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const fromEconItem = (econItem) => (mainFns[econItem.appid] || fromEconItemOther)()(econItem)
|
|
387
415
|
|
|
388
|
-
const fromEconItemOptions = curry((options, econItem) =>
|
|
389
|
-
propEq(440, 'appid'),
|
|
390
|
-
fromEconItem440(options),
|
|
391
|
-
fromEconItemOther(options)
|
|
392
|
-
)(econItem))
|
|
416
|
+
const fromEconItemOptions = curry((options, econItem) => (mainFns[econItem.appid] || fromEconItemOther)(options)(econItem))
|
|
393
417
|
|
|
394
418
|
module.exports = {
|
|
395
419
|
fromEconItem,
|
package/getCollections.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
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')
|
|
1
|
+
const { prop, map, compose, toLower, mapObjIndexed, toPairs, when, has, __, chain, assoc, reduce, mergeRight, values, path, uncurryN, replace, mapKeys } = require('ramda')
|
|
3
2
|
|
|
4
3
|
const simplifyCollections = compose(
|
|
5
4
|
reduce((curr, obj) => mergeRight(curr, obj), {}),
|
|
@@ -15,7 +14,7 @@ const simplifyCollections = compose(
|
|
|
15
14
|
prop('items')
|
|
16
15
|
)
|
|
17
16
|
),
|
|
18
|
-
(collections) =>
|
|
17
|
+
(collections) => mapKeys((key) => replace('#', '', path([key, 'name'], collections)), collections),
|
|
19
18
|
prop('item_collections')
|
|
20
19
|
)
|
|
21
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juice789/tf2items",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
4
4
|
"description": "tf2 item schema thingys",
|
|
5
5
|
"main": "app.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,15 +19,8 @@
|
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/juice789/tf2items/issues"
|
|
21
21
|
},
|
|
22
|
-
"peerDependencies": {
|
|
23
|
-
"axios": "^1.7.2",
|
|
24
|
-
"ramda": "^0.30.1",
|
|
25
|
-
"ramda-adjunct": "^5.0.1",
|
|
26
|
-
"redux-saga": "^1.3.0",
|
|
27
|
-
"vdf": "^0.0.2"
|
|
28
|
-
},
|
|
29
22
|
"devDependencies": {
|
|
30
|
-
"jest": "^
|
|
23
|
+
"jest": "^30.0.5",
|
|
31
24
|
"redux-saga-test-plan": "^4.0.6"
|
|
32
25
|
},
|
|
33
26
|
"publishConfig": {
|
|
@@ -35,6 +28,10 @@
|
|
|
35
28
|
},
|
|
36
29
|
"sideEffects": false,
|
|
37
30
|
"dependencies": {
|
|
38
|
-
"remove-accents": "^0.5.0"
|
|
31
|
+
"remove-accents": "^0.5.0",
|
|
32
|
+
"axios": "^1.11.0",
|
|
33
|
+
"ramda": "^0.31.3",
|
|
34
|
+
"redux-saga": "^1.3.0",
|
|
35
|
+
"vdf": "^0.0.2"
|
|
39
36
|
}
|
|
40
37
|
}
|