@juice789/tf2items 1.0.0 → 1.0.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.
package/api.js CHANGED
@@ -56,4 +56,7 @@ api.getAssetClassInfo = ({ steamApiKey }) => (ids, appId = 440) => myAxios({
56
56
 
57
57
  const createApi = compose(map(__, api), applyTo)
58
58
 
59
- module.exports = createApi
59
+ module.exports = {
60
+ createApi,
61
+ api
62
+ }
package/app.js CHANGED
@@ -8,12 +8,19 @@ const sagaHelpers = require('./sagaHelpers')
8
8
  const items = require('./schemaItems.js')
9
9
  const sku = require('./sku.js')
10
10
  const skuBp = require('./skuBp.js')
11
+ const skuLinks = require('./skuLinks.js')
11
12
 
12
- const createApi = require('./api.js')
13
+ const { createApi, api } = require('./api.js')
13
14
 
14
15
  const sagas = require('./sagas.js')
15
16
  const { saveSchemaSaga } = require('./saveSchema.js')
16
17
 
18
+ const { fromEconItem } = require('./fromEconItem.js')
19
+ const { fromListingV1 } = require('./fromListingV1.js')
20
+ const { fromListingV2 } = require('./fromListingV2.js')
21
+ const { blanketify } = require('./blanket.js')
22
+ const { toSearchParams } = require('./toSearchParams.js')
23
+
17
24
  const getInstance = (options) => {
18
25
  const api = createApi(options)
19
26
  return compose(
@@ -37,6 +44,14 @@ module.exports = {
37
44
  ...skuBp,
38
45
  ...sagas,
39
46
  ...sagaHelpers,
47
+ ...skuLinks,
40
48
  saveSchemaSaga,
41
- getInstance
49
+ getInstance,
50
+ createApi,
51
+ api,
52
+ fromEconItem,
53
+ fromListingV1,
54
+ fromListingV2,
55
+ blanketify,
56
+ toSearchParams
42
57
  }
@@ -32,7 +32,7 @@ const mergeAssetClasses = uncurryN(2, (assetClasses) => compose(
32
32
  groupBy(props(['classid', 'instanceid']))
33
33
  ))
34
34
 
35
- function* fetchAppDataInventory(inventory, d = 1000) {
35
+ function* fetchAppDataInventorySaga(inventory, d = 1000) {
36
36
 
37
37
  let p = 0, assetClasses = {}
38
38
  const { getAssetClassInfo } = yield getContext('api')
@@ -50,5 +50,5 @@ function* fetchAppDataInventory(inventory, d = 1000) {
50
50
  }
51
51
 
52
52
  module.exports = {
53
- fetchAppDataInventory
53
+ fetchAppDataInventorySaga
54
54
  }
package/options.json ADDED
@@ -0,0 +1 @@
1
+ {"steamApiKey": "1E55C647593C029A0C9BE22F97F03F03"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juice789/tf2items",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "tf2 item schema thingys",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -34,4 +34,4 @@
34
34
  "access": "public"
35
35
  },
36
36
  "sideEffects": false
37
- }
37
+ }
package/sagas.js CHANGED
@@ -3,11 +3,13 @@ const { fetchItemsGameSaga } = require('./fetchItemsGame.js')
3
3
  const { fetchParticleEffectsSaga } = require('./fetchParticleEffects.js')
4
4
  const { fetchTexturesSaga } = require('./fetchTextures.js')
5
5
  const { fetchTfEnglishSaga } = require('./fetchTfEnglish.js')
6
+ const { fetchAppDataInventorySaga } = require('./fetchAppDataInventory.js')
6
7
 
7
8
  module.exports = {
8
9
  fetchItemsApiSaga,
9
10
  fetchItemsGameSaga,
10
11
  fetchParticleEffectsSaga,
11
12
  fetchTexturesSaga,
12
- fetchTfEnglishSaga
13
+ fetchTfEnglishSaga,
14
+ fetchAppDataInventorySaga
13
15
  }
package/schemaItems.js CHANGED
@@ -12,4 +12,5 @@ const safeItems = new Proxy(schema.items, {
12
12
  module.exports = {
13
13
  ...schema,
14
14
  safeItems,
15
+ items: schema.items
15
16
  }
package/sku.js CHANGED
@@ -113,7 +113,7 @@ const getName = ({
113
113
  craft && '#' + craft,
114
114
  uncraftable && 'Non-Craftable',
115
115
  elevated && 'Strange',
116
- quality && !['6', '15'].includes(quality.toString()) && (qualityBpStyle ? effect : true) && qualityNames[quality],
116
+ quality && !['6', '15'].includes(quality.toString()) && (qualityBpStyle ? !effect : true) && qualityNames[quality],
117
117
  oq && oq.toString() !== '6' && qualityNames[oq],
118
118
  target && killstreakTier && killstreakTiers[killstreakTier],
119
119
  target && safeItems[target].item_name,
@@ -129,9 +129,9 @@ const getName = ({
129
129
  series && '#' + series
130
130
  ].filter(Boolean).join(' ')
131
131
 
132
- const itemNameFromSku = (sku) => {
132
+ const itemNameFromSku = (sku, ...params) => {
133
133
  const item = itemFromSku(sku)
134
- return getName(item)
134
+ return getName(item, ...params)
135
135
  }
136
136
 
137
137
  module.exports = {
package/skuLinks.js ADDED
@@ -0,0 +1,177 @@
1
+ const {
2
+ itemFromSku
3
+ } = require('./sku.js')
4
+
5
+ const {
6
+ toBpQuality,
7
+ toBpName,
8
+ toBpPriceIndex
9
+ } = require('./skuBp.js')
10
+
11
+ const {
12
+ qualityNames,
13
+ killstreakTiers,
14
+ wears
15
+ } = require('./schemaHelper.json')
16
+
17
+ const {
18
+ safeItems: items
19
+ } = require('./schemaItems.js')
20
+
21
+ const {
22
+ particleEffects,
23
+ textures
24
+ } = require('./schema.json')
25
+
26
+ const manncoUrl = (sku) => {
27
+ const {
28
+ defindex,
29
+ quality,
30
+ uncraftable,
31
+ killstreakTier,
32
+ target,
33
+ output,
34
+ oq,
35
+ elevated,
36
+ festivized,
37
+ texture,
38
+ wear,
39
+ australium,
40
+ series,
41
+ effect
42
+ } = itemFromSku(sku)
43
+
44
+
45
+ const chemSeries = {
46
+ 20000: 1,
47
+ 20005: 2
48
+ }
49
+
50
+ const manncoUrl = [
51
+ 440,
52
+ uncraftable && 'uncraftable',
53
+ oq && oq !== '6' && qualityNames[oq],
54
+ effect && particleEffects[effect],
55
+ elevated && 'strange',
56
+ ['6', '15'].includes(quality) === false && qualityNames[quality],
57
+ festivized && 'festivized',
58
+ killstreakTier && killstreakTiers[killstreakTier],
59
+ australium && 'australium',
60
+ texture && textures[texture],
61
+ target && items[target].item_name,
62
+ output && items[output].item_name,
63
+ items[defindex].item_name.replace('\\n', ' '),
64
+ wear && wears[wear],
65
+ chemSeries[defindex] && 'series-' + chemSeries[defindex],
66
+ series && (!items[defindex].seriesHidden || ['111', '112', '113', '114', '115', '116'].includes(series)) && 'series-' + series
67
+ ].filter(Boolean).join('-').replaceAll(/[^0-9a-zA-Z -]/g, '').replaceAll(' ', '-').toLowerCase()
68
+
69
+ return 'https://mannco.store/item/' + manncoUrl
70
+ }
71
+
72
+ const scmUrl = (sku) => {
73
+
74
+ const {
75
+ defindex,
76
+ quality,
77
+ killstreakTier,
78
+ target,
79
+ output,
80
+ oq,
81
+ elevated,
82
+ festivized,
83
+ texture,
84
+ wear,
85
+ australium,
86
+ series
87
+ } = itemFromSku(sku)
88
+
89
+ const chemSeries = {
90
+ 20000: 1,
91
+ 20005: 2
92
+ }
93
+
94
+ const scmUrl = [
95
+ oq && oq !== '6' && qualityNames[oq],
96
+ elevated && 'Strange',
97
+ !['6', '15'].includes(quality) && qualityNames[quality],
98
+ festivized && 'Festivized',
99
+ killstreakTier && killstreakTiers[killstreakTier],
100
+ australium && 'Australium',
101
+ texture && textures[texture],
102
+ target && items[target].item_name,
103
+ output && items[output].item_name,
104
+ items[defindex].item_name,
105
+ wear && '(' + wears[wear] + ')',
106
+ chemSeries[defindex] && 'Series%20%23' + chemSeries[defindex],
107
+ series && !items[defindex].seriesHidden && 'Series%20%23' + series
108
+ ].filter(Boolean).join(' ')
109
+
110
+
111
+ return 'https://steamcommunity.com/market/listings/440/' + scmUrl
112
+ }
113
+
114
+ const bpUrl = (sku) => {
115
+
116
+ const {
117
+ uncraftable
118
+ } = itemFromSku(sku)
119
+
120
+ const bpUrl = [
121
+ toBpQuality(sku),
122
+ toBpName(sku),
123
+ 'Tradable',
124
+ uncraftable === true ? 'Non-Craftable' : 'Craftable',
125
+ toBpPriceIndex(sku)
126
+ ].filter(Boolean).join('/').replace('%', '%25').replace('%250A', '%0A')
127
+
128
+ return 'https://backpack.tf/stats/' + bpUrl
129
+ }
130
+
131
+ const marketplaceUrl = (sku) => {
132
+ const {
133
+ defindex,
134
+ quality,
135
+ uncraftable,
136
+ killstreakTier,
137
+ target,
138
+ output,
139
+ oq,
140
+ elevated,
141
+ festivized,
142
+ texture,
143
+ wear,
144
+ australium,
145
+ series,
146
+ craft,
147
+ effect
148
+ } = itemFromSku(sku)
149
+
150
+
151
+ const marketplaceSku = [
152
+ defindex,
153
+ quality,
154
+ effect && 'u' + effect,
155
+ wear && 'w' + wear,
156
+ texture && 'pk' + texture,
157
+ elevated && 'strange',
158
+ series && 'c' + series,
159
+ craft && 'n' + craft,
160
+ uncraftable && 'uncraftable',
161
+ australium && 'australium',
162
+ killstreakTier && 'kt-' + killstreakTier,
163
+ festivized && 'festive',
164
+ target && 'td-' + target,
165
+ output && 'od-' + output,
166
+ oq && 'oq-' + oq
167
+ ].filter(Boolean).join(';')
168
+
169
+ return 'https://marketplace.tf/items/tf2/' + marketplaceSku
170
+ }
171
+
172
+ module.exports = {
173
+ manncoUrl,
174
+ marketplaceUrl,
175
+ bpUrl,
176
+ scmUrl
177
+ }