@tf2-automatic/tf2-format 9.3.0-dev.3 → 10.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.
Files changed (53) hide show
  1. package/README.md +124 -7
  2. package/package.json +1 -1
  3. package/src/index.d.ts +1 -0
  4. package/src/index.js +1 -0
  5. package/src/index.js.map +1 -1
  6. package/src/lib/common.d.ts +29 -0
  7. package/src/lib/common.js +33 -0
  8. package/src/lib/common.js.map +1 -0
  9. package/src/lib/naming/index.d.ts +2 -1
  10. package/src/lib/naming/index.js +21 -26
  11. package/src/lib/naming/index.js.map +1 -1
  12. package/src/lib/parsing/bptf/parser.d.ts +8 -0
  13. package/src/lib/parsing/bptf/parser.js +89 -0
  14. package/src/lib/parsing/bptf/parser.js.map +1 -0
  15. package/src/lib/parsing/bptf/types.d.ts +94 -0
  16. package/src/lib/parsing/bptf/types.js +3 -0
  17. package/src/lib/parsing/bptf/types.js.map +1 -0
  18. package/src/lib/parsing/econ/parser.d.ts +3 -9
  19. package/src/lib/parsing/econ/parser.js +74 -138
  20. package/src/lib/parsing/econ/parser.js.map +1 -1
  21. package/src/lib/parsing/econ/types.d.ts +1 -1
  22. package/src/lib/parsing/helpers.d.ts +7 -0
  23. package/src/lib/parsing/helpers.js +105 -0
  24. package/src/lib/parsing/helpers.js.map +1 -0
  25. package/src/lib/parsing/index.d.ts +3 -1
  26. package/src/lib/parsing/index.js +3 -1
  27. package/src/lib/parsing/index.js.map +1 -1
  28. package/src/lib/parsing/parser.d.ts +4 -4
  29. package/src/lib/parsing/parser.js.map +1 -1
  30. package/src/lib/parsing/tf2/parser.d.ts +9 -10
  31. package/src/lib/parsing/tf2/parser.js +123 -384
  32. package/src/lib/parsing/tf2/parser.js.map +1 -1
  33. package/src/lib/parsing/tf2/types.d.ts +12 -59
  34. package/src/lib/parsing/tf2-api/parser.d.ts +10 -0
  35. package/src/lib/parsing/tf2-api/parser.js +128 -0
  36. package/src/lib/parsing/tf2-api/parser.js.map +1 -0
  37. package/src/lib/parsing/tf2-api/types.d.ts +47 -0
  38. package/src/lib/parsing/tf2-api/types.js +3 -0
  39. package/src/lib/parsing/tf2-api/types.js.map +1 -0
  40. package/src/lib/parsing/tf2-gc/constants.js.map +1 -0
  41. package/src/lib/parsing/tf2-gc/parser.d.ts +12 -0
  42. package/src/lib/parsing/tf2-gc/parser.js +277 -0
  43. package/src/lib/parsing/tf2-gc/parser.js.map +1 -0
  44. package/src/lib/parsing/tf2-gc/types.d.ts +43 -0
  45. package/src/lib/parsing/tf2-gc/types.js +3 -0
  46. package/src/lib/parsing/tf2-gc/types.js.map +1 -0
  47. package/src/lib/schemas.d.ts +65 -0
  48. package/src/lib/schemas.js +3 -0
  49. package/src/lib/schemas.js.map +1 -0
  50. package/src/lib/types.d.ts +11 -323
  51. package/src/lib/parsing/tf2/constants.js.map +0 -1
  52. /package/src/lib/parsing/{tf2 → tf2-gc}/constants.d.ts +0 -0
  53. /package/src/lib/parsing/{tf2 → tf2-gc}/constants.js +0 -0
package/README.md CHANGED
@@ -1,23 +1,140 @@
1
1
  # tf2-format
2
2
 
3
- This is a standard library for working with different formats in Team Fortress 2. It is designed with speed and interoperability in mind, and it is a many times faster than alternatives.
3
+ This is a fast, stateless, and extensible library for working with Team Fortress 2 item formats. It uses a single, unified schema, to convert item data across different formats. It is designed for speed, reliability, and interoperability - it has no hardcoded values, no internal state, and doesn't assume where your data comes from. It makes working with TF2 items simple, efficient, and dependable.
4
+
5
+ The library is well suitable for distributed environments where a centralized schema registry is used, such as [@tf2-automatic/item-service](../../apps/item-service).
4
6
 
5
7
  ## Why another library?
6
8
 
7
- I created this library because I needed fast, simple, and reliable handling of different formats in Team Fortress 2. Other libraries are slow, complicated, and rely heavily on hard-coded values. This library can parse different formats into a single common format.
9
+ I created this library because I needed fast, simple, and reliable handling of different formats in Team Fortress 2. While there are many existing solutions, most suffer from the same core issues: they are slow, rely heavily on hard-coded logic, assume all data is stored in memory, and don't integrate well with each other due to incompatible formats or edge cases.
10
+
11
+ This library addresses those problems with a different approach: it is stateless, modular, and built around a shared, extensible schema. Instead of hardcoding logic or assuming all data is available locally and upfront, it delegates data access to the user through a clean interface. Additionally, this library is designed to avoid blocking Node.js's main event loop with heavy synchronous tasks.
12
+
13
+ The design is guided by the following principles:
14
+
15
+ - **Consistency**: Eliminates ambiguity by enforcing a single schema across formats.
16
+ - **Speed**: Significantly faster than alternatives while remaining accurate.
17
+ - **Interoperability**: Easy to convert between different formats.
18
+ - **Reliability**: Avoids reliance on hard-coded edge cases; all logic is explicit and predictable.
19
+ - **Statelessness**: The library does not store, cache, or batch data. It leaves full control of data flow to the user.
20
+
21
+ These principles ensure the library is simple to use and is something you can rely on.
22
+
23
+ ## Getting started
24
+
25
+ The library can be installed from [npm](https://www.npmjs.com/package/@tf2-automatic/tf2-format) using the following command:
26
+
27
+ ```$ npm install @tf2-automatic/tf2-format```
28
+
29
+ ### Example
30
+
31
+ Once installed, you can implement a schema to parse TF2 items, as shown in the example below.
32
+
33
+ ```ts
34
+ import {
35
+ TF2ParserSchema,
36
+ TF2APIParser,
37
+ TF2APIItem,
38
+ SKU,
39
+ Item,
40
+ InventoryItem,
41
+ ItemsGameItem,
42
+ } from '@tf2-automatic/tf2-format';
43
+
44
+ // Example stores mapping keys to values
45
+
46
+ const items: Record<string, ItemsGameItem> = {
47
+ // Mann Co. Supply Crate Key (defindex as string key)
48
+ '5021': {
49
+ name: 'Decoder Ring',
50
+ attributes: {
51
+ 'always tradable': {
52
+ attribute_class: 'always_tradable',
53
+ value: '1',
54
+ },
55
+ },
56
+ static_attrs: {
57
+ 'is commodity': '1',
58
+ },
59
+ },
60
+ };
61
+
62
+ const paint: Record<string, number> = {
63
+ 'e7b53b': 5037, // Australium Gold
64
+ 'b8383b': 5046, // Team Spirit (RED team hex color)
65
+ };
66
+
67
+ const parts: Record<string, number | null> = {
68
+ '87': 6060, // Strange Part: Headshot Kills (87 is the kill eater id)
69
+ };
70
+
71
+ // Define the schema for the parser
72
+ const schema: TF2ParserSchema = {
73
+ getItemsGameItemByDefindex: (defindex) => items[String(defindex)],
74
+ fetchItemsGameItemByDefindex: (defindex) => Promise.resolve(items[String(defindex)]),
75
+ getPaintByColor: (color) => paint[color],
76
+ fetchPaintByColor: (color) => Promise.resolve(paint[color]),
77
+ getStrangePartById: (id) => parts[id],
78
+ fetchStrangePartById: (id) => Promise.resolve(parts[id]),
79
+ };
80
+
81
+ // Create a parser instance with the schema
82
+ const parser = new TF2APIParser(schema);
8
83
 
9
- ## Guides
84
+ // Example TF2 API item (fill with actual data)
85
+ const item: TF2APIItem = { /* ... */ };
10
86
 
11
- This library is organized into different classes, each made for working with specific formats. By separating functionality this way, you can easily find and work with the format you need without unnecessary complexity.
87
+ // Extract information without using the schema
88
+ const [extracted, context] = parser.extract(item);
89
+
90
+ // Parse the extracted data into common format using the schema
91
+ const parsed: InventoryItem = await parser.parse(extracted, context);
92
+
93
+ // Convert parsed item into string
94
+ const sku: string = SKU.fromObject(parsed);
95
+
96
+ // Convert string back into common format
97
+ const object: Item = SKU.fromString(sku);
98
+ ```
99
+
100
+ This example demonstrates how to define a schema, create a parser using that schema, and convert between item formats and SKUs.
101
+
102
+ ## Main concepts
103
+
104
+ This library is organized into different classes and types, each made for working with specific formats. By separating functionality this way, you can easily work with the format you need without unnecessary complexity.
105
+
106
+ ### Schemas
107
+
108
+ Schemas define common methods for retrieving external information about TF2 items during parsing. The library **does not** store, cache, or batch any data and maintains **no internal state**. All data access must be implemented externally by the user through the schema methods, allowing flexible integration with any data source - whether it is in-memory, file-based, remote APIs, or databases.
109
+
110
+ Information retrieval is organized into distinct **subschemas**, each being responsible for specific schema information. Each subschema provides:
111
+
112
+ - A synchronous `get` method for fast, local lookups.
113
+ - An asynchronous `fetch` method for retrieving data from external sources.
114
+
115
+ This design prioritizes speed and memory efficiency by leveraging quick local access while supporting on-demand external data retrieval.
12
116
 
13
117
  ### Item parsing
14
118
 
15
- For parsing items, e.g. econ items from inventories and trades, or TF2 items from the TF2 GC ([node-tf2](https://github.com/DoctorMckay/node-tf2)), use one of the implementations of the `Parser` class. For parsing econ items, use the [EconParser](./src/lib/parsing/econ) class. For parsing tf2 items, use the [TF2Parser](./src/lib/parsing/tf2) class. See [here](./src/lib/parsing/) for the item parser documentation.
119
+ The item parsers are primarily focused on parsing inventory items from various sources, but it can also be used to parse items from backpack.tf listings.
120
+
121
+ There are a total of four item parsers:
122
+
123
+ - [EconParser](./src/lib/parsing/econ) for parsing [Steam economy](https://github.com/DoctorMcKay/node-steam-tradeoffer-manager/wiki/EconItem) items (inventories and trade offers).
124
+ - [TF2GCParser](./src/lib/parsing/tf2-gc) for parsing items from the [node-tf2](https://github.com/DoctorMckay/node-tf2) library.
125
+ - [TF2APIParser](./src/lib/parsing/tf2-api) for parsing items from the [GetPlayerItems API](https://wiki.teamfortress.com/wiki/WebAPI/GetPlayerItems).
126
+ - [BptfParser](./src/lib/parsing/bptf) for parsing items from [backpack.tf](https://next.backpack.tf/developer) listings.
127
+
128
+ You can read more about the item parsers [here](./src/lib/parsing/).
16
129
 
17
130
  ### SKU
18
131
 
19
- For working with SKUs, use the [SKU](./src/lib/sku) class.
132
+ A TF2 SKU is a human-readable string that uniquely identifies an item. It can greatly simplify code by encoding key properties into a compact format and are commonly used by trading bots and APIs.
133
+
134
+ You can read more about working with SKUs [here](./src/lib/sku).
20
135
 
21
136
  ### Generating names
22
137
 
23
- For generating the name of items, use the [NameGenerator](./src/lib/naming) class.
138
+ You can generate names of items using the common format. The names closely matches the in-game item naming and is useful for displaying information in a user-friendly way.
139
+
140
+ You can read more about generating the name of items [here](./src/lib/naming).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tf2-automatic/tf2-format",
3
- "version": "9.3.0-dev.3",
3
+ "version": "10.0.0",
4
4
  "dependencies": {
5
5
  "tslib": "^2.7.0",
6
6
  "protobufjs": "^7.4.0"
package/src/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './lib/types';
2
2
  export * from './lib/parsing';
3
3
  export * from './lib/sku';
4
4
  export * from './lib/naming';
5
+ export * from './lib/schemas';
package/src/index.js CHANGED
@@ -5,4 +5,5 @@ tslib_1.__exportStar(require("./lib/types"), exports);
5
5
  tslib_1.__exportStar(require("./lib/parsing"), exports);
6
6
  tslib_1.__exportStar(require("./lib/sku"), exports);
7
7
  tslib_1.__exportStar(require("./lib/naming"), exports);
8
+ tslib_1.__exportStar(require("./lib/schemas"), exports);
8
9
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/tf2-format/src/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,wDAA8B;AAC9B,oDAA0B;AAC1B,uDAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/tf2-format/src/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,wDAA8B;AAC9B,oDAA0B;AAC1B,uDAA6B;AAC7B,wDAA8B"}
@@ -0,0 +1,29 @@
1
+ export declare const KILLSTREAK_FABRICATORS: {
2
+ 1: number;
3
+ 2: number;
4
+ 3: number;
5
+ };
6
+ export declare const KILLSTREAK_NAMES_TO_TIERS: {
7
+ Killstreak: number;
8
+ 'Specialized Killstreak': number;
9
+ 'Professional Killstreak': number;
10
+ };
11
+ export declare const KILLSTREAK_TIERS_TO_NAMES: {
12
+ 1: string;
13
+ 2: string;
14
+ 3: string;
15
+ };
16
+ export declare const WEAR_NAMES_TO_LEVELS: {
17
+ 'Factory New': number;
18
+ 'Minimal Wear': number;
19
+ 'Field-Tested': number;
20
+ 'Well-Worn': number;
21
+ 'Battle Scarred': number;
22
+ };
23
+ export declare const WEAR_LEVELS_TO_NAMES: {
24
+ 1: string;
25
+ 2: string;
26
+ 3: string;
27
+ 4: string;
28
+ 5: string;
29
+ };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WEAR_LEVELS_TO_NAMES = exports.WEAR_NAMES_TO_LEVELS = exports.KILLSTREAK_TIERS_TO_NAMES = exports.KILLSTREAK_NAMES_TO_TIERS = exports.KILLSTREAK_FABRICATORS = void 0;
4
+ exports.KILLSTREAK_FABRICATORS = {
5
+ 1: 6527,
6
+ 2: 6523,
7
+ 3: 6526,
8
+ };
9
+ exports.KILLSTREAK_NAMES_TO_TIERS = {
10
+ Killstreak: 1,
11
+ 'Specialized Killstreak': 2,
12
+ 'Professional Killstreak': 3,
13
+ };
14
+ exports.KILLSTREAK_TIERS_TO_NAMES = {
15
+ 1: 'Killstreak',
16
+ 2: 'Specialized Killstreak',
17
+ 3: 'Professional Killstreak',
18
+ };
19
+ exports.WEAR_NAMES_TO_LEVELS = {
20
+ 'Factory New': 1,
21
+ 'Minimal Wear': 2,
22
+ 'Field-Tested': 3,
23
+ 'Well-Worn': 4,
24
+ 'Battle Scarred': 5,
25
+ };
26
+ exports.WEAR_LEVELS_TO_NAMES = {
27
+ 1: 'Factory New',
28
+ 2: 'Minimal Wear',
29
+ 3: 'Field-Tested',
30
+ 4: 'Well-Worn',
31
+ 5: 'Battle Scarred',
32
+ };
33
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../libs/tf2-format/src/lib/common.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG;IACpC,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;CACR,CAAC;AAEW,QAAA,yBAAyB,GAAG;IACvC,UAAU,EAAE,CAAC;IACb,wBAAwB,EAAE,CAAC;IAC3B,yBAAyB,EAAE,CAAC;CAC7B,CAAC;AAEW,QAAA,yBAAyB,GAAG;IACvC,CAAC,EAAE,YAAY;IACf,CAAC,EAAE,wBAAwB;IAC3B,CAAC,EAAE,yBAAyB;CAC7B,CAAC;AAEW,QAAA,oBAAoB,GAAG;IAClC,aAAa,EAAE,CAAC;IAChB,cAAc,EAAE,CAAC;IACjB,cAAc,EAAE,CAAC;IACjB,WAAW,EAAE,CAAC;IACd,gBAAgB,EAAE,CAAC;CACpB,CAAC;AAEW,QAAA,oBAAoB,GAAG;IAClC,CAAC,EAAE,aAAa;IAChB,CAAC,EAAE,cAAc;IACjB,CAAC,EAAE,cAAc;IACjB,CAAC,EAAE,WAAW;IACd,CAAC,EAAE,gBAAgB;CACpB,CAAC"}
@@ -1,4 +1,5 @@
1
- import { ItemNamingSchema, RequiredItemAttributes } from '../types';
1
+ import { ItemNamingSchema } from '../schemas';
2
+ import { RequiredItemAttributes } from '../types';
2
3
  export declare class NameGenerator {
3
4
  private readonly schema;
4
5
  constructor(schema: ItemNamingSchema);
@@ -2,18 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NameGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const KILLSTREAKS = [
6
- 'Killstreak',
7
- 'Specialized Killstreak',
8
- 'Professional Killstreak',
9
- ];
10
- const WEAR = [
11
- 'Factory New',
12
- 'Minimal Wear',
13
- 'Field-Tested',
14
- 'Well-Worn',
15
- 'Battle Scarred',
16
- ];
5
+ const common_1 = require("../common");
17
6
  class NameGenerator {
18
7
  constructor(schema) {
19
8
  this.schema = schema;
@@ -21,9 +10,9 @@ class NameGenerator {
21
10
  getName(item_1) {
22
11
  return tslib_1.__awaiter(this, arguments, void 0, function* (item, proper = true) {
23
12
  let name = '';
24
- let schemaItem = this.schema.getItemByDefindex(item.defindex);
13
+ let schemaItem = this.schema.getSchemaItemByDefindex(item.defindex);
25
14
  if (schemaItem === undefined) {
26
- schemaItem = yield this.schema.fetchItemByDefindex(item.defindex);
15
+ schemaItem = yield this.schema.fetchSchemaItemByDefindex(item.defindex);
27
16
  }
28
17
  else if (schemaItem instanceof Error) {
29
18
  throw schemaItem;
@@ -46,7 +35,7 @@ class NameGenerator {
46
35
  }
47
36
  if ((item.quality === 6 && item.elevated === true) ||
48
37
  (item.quality !== 6 && item.quality !== 15 && item.quality !== 5) ||
49
- (item.quality === 5 && !item.effect) ||
38
+ (item.quality === 5 && item.effect === undefined) ||
50
39
  schemaItem.item_quality === 5) {
51
40
  let quality = this.schema.getQualityById(item.quality);
52
41
  if (quality === undefined) {
@@ -58,12 +47,18 @@ class NameGenerator {
58
47
  name += quality + ' ';
59
48
  }
60
49
  if (typeof item.effect === 'number') {
61
- let effect = this.schema.getEffectById(item.effect);
62
- if (effect === undefined) {
63
- effect = yield this.schema.fetchEffectById(item.effect);
50
+ let effect = undefined;
51
+ if (item.effect === 0) {
52
+ effect = 'Invalid Particle';
64
53
  }
65
- else if (effect instanceof Error) {
66
- throw effect;
54
+ else {
55
+ effect = this.schema.getEffectById(item.effect);
56
+ if (effect === undefined) {
57
+ effect = yield this.schema.fetchEffectById(item.effect);
58
+ }
59
+ else if (effect instanceof Error) {
60
+ throw effect;
61
+ }
67
62
  }
68
63
  name += effect + ' ';
69
64
  }
@@ -71,12 +66,12 @@ class NameGenerator {
71
66
  name += 'Festivized ';
72
67
  }
73
68
  if (item.killstreak !== undefined && item.killstreak !== 0) {
74
- name += KILLSTREAKS[item.killstreak - 1] + ' ';
69
+ name += common_1.KILLSTREAK_TIERS_TO_NAMES[item.killstreak] + ' ';
75
70
  }
76
71
  if (typeof item.target === 'number') {
77
- let target = this.schema.getItemByDefindex(item.target);
72
+ let target = this.schema.getSchemaItemByDefindex(item.target);
78
73
  if (target === undefined) {
79
- target = yield this.schema.fetchItemByDefindex(item.target);
74
+ target = yield this.schema.fetchSchemaItemByDefindex(item.target);
80
75
  }
81
76
  else if (target instanceof Error) {
82
77
  throw target;
@@ -94,9 +89,9 @@ class NameGenerator {
94
89
  name += quality + ' ';
95
90
  }
96
91
  if (typeof item.output === 'number') {
97
- let output = this.schema.getItemByDefindex(item.output);
92
+ let output = this.schema.getSchemaItemByDefindex(item.output);
98
93
  if (output === undefined) {
99
- output = yield this.schema.fetchItemByDefindex(item.output);
94
+ output = yield this.schema.fetchSchemaItemByDefindex(item.output);
100
95
  }
101
96
  else if (output instanceof Error) {
102
97
  throw output;
@@ -121,7 +116,7 @@ class NameGenerator {
121
116
  }
122
117
  name += schemaItem.item_name;
123
118
  if (item.wear) {
124
- name += ' (' + WEAR[item.wear - 1] + ')';
119
+ name += ' (' + common_1.WEAR_LEVELS_TO_NAMES[item.wear] + ')';
125
120
  }
126
121
  if (typeof item.crateSeries === 'number') {
127
122
  name += ' #' + item.crateSeries;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/tf2-format/src/lib/naming/index.ts"],"names":[],"mappings":";;;;AAEA,MAAM,WAAW,GAAG;IAClB,YAAY;IACZ,wBAAwB;IACxB,yBAAyB;CAC1B,CAAC;AACF,MAAM,IAAI,GAAG;IACX,aAAa;IACb,cAAc;IACd,cAAc;IACd,WAAW;IACX,gBAAgB;CACjB,CAAC;AAEF,MAAa,aAAa;IACxB,YAA6B,MAAwB;QAAxB,WAAM,GAAN,MAAM,CAAkB;IAAG,CAAC;IAEnD,OAAO;qEAAC,IAA4B,EAAE,MAAM,GAAG,IAAI;YACvD,IAAI,IAAI,GAAG,EAAE,CAAC;YAEd,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9D,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC7B,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpE,CAAC;iBAAM,IAAI,UAAU,YAAY,KAAK,EAAE,CAAC;gBACvC,MAAM,UAAU,CAAC;YACnB,CAAC;YAED,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;gBAC5B,IAAI,IAAI,eAAe,CAAC;YAC1B,CAAC;YAED,IAAI,IAAI,CAAC,SAAS,KAAK,KA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OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBACtC,IAAI,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC1D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;oBAC3B,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAChE,CAAC;qBAAM,IAAI,QAAQ,YAAY,KAAK,EAAE,CAAC;oBACrC,MAAM,QAAQ,CAAC;gBACjB,CAAC;gBAED,IAAI,IAAI,QAAQ,GAAG,GAAG,CAAC;YACzB,CAAC;YAED,IAAI,MAAM,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE,IAAI,UAAU,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;gBACtE,IAAI,GAAG,MAAM,CAAC;YAChB,CAAC;YAED,IAAI,IAAI,UAAU,CAAC,SAAS,CAAC;YAE7B,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,IAAI,IAAI,IAAI,GAAG,6BAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;YACvD,CAAC;YAED,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;gBACzC,IAAI,IAAI,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC;YAClC,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;CACF;AAzID,sCAyIC"}
@@ -0,0 +1,8 @@
1
+ import { Parser } from '../parser';
2
+ import { PossibleInventoryItem } from '../../types';
3
+ import { BptfExtractedItem, BptfItem } from './types';
4
+ import { BptfParserSchema } from '../../schemas';
5
+ export declare class BptfParser extends Parser<BptfParserSchema, BptfItem, BptfExtractedItem> {
6
+ extract(raw: BptfItem): BptfExtractedItem;
7
+ parse(extracted: BptfExtractedItem): Promise<PossibleInventoryItem>;
8
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BptfParser = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const parser_1 = require("../parser");
6
+ const helpers = tslib_1.__importStar(require("../helpers"));
7
+ class BptfParser extends parser_1.Parser {
8
+ extract(raw) {
9
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
10
+ if (raw.appid !== 440) {
11
+ throw new Error('Item is not from Team Fortress 2 (appid: ' + raw.appid + ')');
12
+ }
13
+ return {
14
+ assetid: raw.id !== '' ? raw.id : null,
15
+ originalId: raw.originalId !== '' ? raw.originalId : null,
16
+ defindex: raw.defindex,
17
+ quality: raw.quality.id,
18
+ // It is not craftable if the key is missing.
19
+ craftable: (_a = raw.craftable) !== null && _a !== void 0 ? _a : false,
20
+ // It is not tradable if the key is missing.
21
+ tradable: (_b = raw.tradable) !== null && _b !== void 0 ? _b : false,
22
+ australium: (_c = raw.australium) !== null && _c !== void 0 ? _c : false,
23
+ festivized: (_d = raw.festivized) !== null && _d !== void 0 ? _d : false,
24
+ effect: (_f = (_e = raw.particle) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : null,
25
+ wear: (_h = (_g = raw.wearTier) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : null,
26
+ paintkit: (_k = (_j = raw.texture) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : null,
27
+ killstreak: (_l = raw.killstreakTier) !== null && _l !== void 0 ? _l : 0,
28
+ target: (_q = (_p = (_o = (_m = raw.recipe) === null || _m === void 0 ? void 0 : _m.targetItem) === null || _o === void 0 ? void 0 : _o._source) === null || _p === void 0 ? void 0 : _p.defindex) !== null && _q !== void 0 ? _q : null,
29
+ output: (_t = (_s = (_r = raw.recipe) === null || _r === void 0 ? void 0 : _r.outputItem) === null || _s === void 0 ? void 0 : _s.defindex) !== null && _t !== void 0 ? _t : null,
30
+ outputQuality: (_x = (_w = (_v = (_u = raw.recipe) === null || _u === void 0 ? void 0 : _u.outputItem) === null || _v === void 0 ? void 0 : _v.quality) === null || _w === void 0 ? void 0 : _w.id) !== null && _x !== void 0 ? _x : null,
31
+ elevatedQuality: (_z = (_y = raw.elevatedQuality) === null || _y === void 0 ? void 0 : _y.id) !== null && _z !== void 0 ? _z : null,
32
+ crateSeries: (_0 = raw.crateSeries) !== null && _0 !== void 0 ? _0 : null,
33
+ paint: (_2 = (_1 = raw.paint) === null || _1 === void 0 ? void 0 : _1.id) !== null && _2 !== void 0 ? _2 : null,
34
+ parts: raw.strangeParts
35
+ ? raw.strangeParts.map((part) => part.killEater.item.defindex)
36
+ : [],
37
+ spells: raw.spells ? raw.spells.map((spell) => spell.name) : [],
38
+ sheen: (_4 = (_3 = raw.sheen) === null || _3 === void 0 ? void 0 : _3.id) !== null && _4 !== void 0 ? _4 : null,
39
+ killstreaker: (_6 = (_5 = raw.killstreaker) === null || _5 === void 0 ? void 0 : _5.id) !== null && _6 !== void 0 ? _6 : null,
40
+ inputs: (_8 = (_7 = raw.recipe) === null || _7 === void 0 ? void 0 : _7.inputItems) !== null && _8 !== void 0 ? _8 : [],
41
+ quantity: (_9 = raw.quantity) !== null && _9 !== void 0 ? _9 : null,
42
+ level: (_10 = raw.level) !== null && _10 !== void 0 ? _10 : null,
43
+ };
44
+ }
45
+ parse(extracted) {
46
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
47
+ var _a;
48
+ let killstreak = extracted.killstreak;
49
+ // Fixes a problem with backpack.tf not returning the killstreak tier of Killstreak Kit Fabricators...
50
+ if (killstreak === 0) {
51
+ if (extracted.killstreaker) {
52
+ killstreak = 3;
53
+ }
54
+ else if (extracted.sheen) {
55
+ killstreak = 2;
56
+ }
57
+ }
58
+ const spells = yield helpers.getSpellByName(extracted.spells, this.schema);
59
+ const inputs = yield helpers.parseInputs(extracted.inputs, this.schema);
60
+ return {
61
+ assetid: extracted.assetid,
62
+ defindex: extracted.defindex,
63
+ quality: extracted.quality,
64
+ craftable: extracted.craftable,
65
+ tradable: extracted.tradable,
66
+ australium: extracted.australium,
67
+ festivized: extracted.festivized,
68
+ effect: extracted.effect,
69
+ wear: extracted.wear,
70
+ paintkit: extracted.paintkit,
71
+ killstreak,
72
+ target: extracted.target,
73
+ output: extracted.output,
74
+ outputQuality: extracted.outputQuality,
75
+ elevated: extracted.elevatedQuality === 11,
76
+ crateSeries: extracted.crateSeries,
77
+ paint: extracted.paint,
78
+ parts: extracted.parts,
79
+ spells,
80
+ sheen: extracted.sheen,
81
+ killstreaker: extracted.killstreaker,
82
+ inputs,
83
+ quantity: (_a = extracted.quantity) !== null && _a !== void 0 ? _a : 1,
84
+ };
85
+ });
86
+ }
87
+ }
88
+ exports.BptfParser = BptfParser;
89
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../../../../libs/tf2-format/src/lib/parsing/bptf/parser.ts"],"names":[],"mappings":";;;;AAAA,sCAAmC;AAInC,4DAAsC;AAEtC,MAAa,UAAW,SAAQ,eAI/B;IACC,OAAO,CAAC,GAAa;;QACnB,IAAI,GAAG,CAAC,KAAK,KAAK,GAAG,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,2CAA2C,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,CAC9D,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;YACtC,UAAU,EAAE,GAAG,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI;YACzD,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,OAAO,EAAE,G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B,OAAO,EAAE,SAAS,CAAC,OAAO;gBAC1B,SAAS,EAAE,SAAS,CAAC,SAAS;gBAC9B,QAAQ,EAAE,SAAS,CAAC,QAAQ;gBAC5B,UAAU,EAAE,SAAS,CAAC,UAAU;gBAChC,UAAU,EAAE,SAAS,CAAC,UAAU;gBAChC,MAAM,EAAE,SAAS,CAAC,MAAM;gBACxB,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,QAAQ,EAAE,SAAS,CAAC,QAAQ;gBAC5B,UAAU;gBACV,MAAM,EAAE,SAAS,CAAC,MAAM;gBACxB,MAAM,EAAE,SAAS,CAAC,MAAM;gBACxB,aAAa,EAAE,SAAS,CAAC,aAAa;gBACtC,QAAQ,EAAE,SAAS,CAAC,eAAe,KAAK,EAAE;gBAC1C,WAAW,EAAE,SAAS,CAAC,WAAW;gBAClC,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,MAAM;gBACN,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,YAAY,EAAE,SAAS,CAAC,YAAY;gBACpC,MAAM;gBACN,QAAQ,EAAE,MAAA,SAAS,CAAC,QAAQ,mCAAI,CAAC;aAClC,CAAC;QACJ,CAAC;KAAA;CACF;AAzFD,gCAyFC"}
@@ -0,0 +1,94 @@
1
+ import { SchemaItem } from '../../types';
2
+ import { ExtractedRecipeInput } from '../econ/types';
3
+ export interface BptfItem {
4
+ appid: number;
5
+ baseName: string;
6
+ defindex: number;
7
+ id: string;
8
+ originalId: string;
9
+ quality: IdNameAndColor;
10
+ elevatedQuality?: IdNameAndColor;
11
+ texture?: Texture;
12
+ particle?: IdAndName;
13
+ tradable?: boolean;
14
+ australium?: boolean;
15
+ festivized?: boolean;
16
+ craftable?: boolean;
17
+ quantity?: number;
18
+ priceindex?: string;
19
+ killstreakTier?: number;
20
+ spells?: Spell[];
21
+ wearTier?: IdAndName;
22
+ recipe?: Recipe;
23
+ sheen?: IdAndName;
24
+ killstreaker?: IdAndName;
25
+ crateSeries?: number;
26
+ paint?: IdNameAndColor;
27
+ level?: number;
28
+ killEaters?: KillEater[];
29
+ strangeParts?: StrangePart[];
30
+ craftNumber?: number;
31
+ }
32
+ interface Spell {
33
+ name: string;
34
+ }
35
+ interface KillEater {
36
+ killEater: NameAndMaybeId;
37
+ }
38
+ interface StrangePart {
39
+ killEater: IdAndName & {
40
+ item: BptfItem;
41
+ };
42
+ }
43
+ interface IdAndName {
44
+ id: number;
45
+ name: string;
46
+ }
47
+ interface IdNameAndColor extends IdAndName {
48
+ color: string;
49
+ }
50
+ interface NameAndMaybeId {
51
+ id?: number;
52
+ name: string;
53
+ }
54
+ interface Recipe {
55
+ inputItems: ExtractedRecipeInput[];
56
+ outputItem: BptfItem | null;
57
+ targetItem: TargetItem | null;
58
+ }
59
+ interface TargetItem {
60
+ itemName: string;
61
+ _source: SchemaItem;
62
+ }
63
+ interface Texture extends IdAndName {
64
+ itemDefindex: number;
65
+ rarity: IdNameAndColor;
66
+ }
67
+ export interface BptfExtractedItem {
68
+ assetid: string | null;
69
+ originalId: string | null;
70
+ level: number | null;
71
+ defindex: number;
72
+ quality: number;
73
+ elevatedQuality: number | null;
74
+ craftable: boolean;
75
+ tradable: boolean;
76
+ australium: boolean;
77
+ festivized: boolean;
78
+ effect: number | null;
79
+ wear: number | null;
80
+ paint: number | null;
81
+ killstreak: number;
82
+ sheen: number | null;
83
+ killstreaker: number | null;
84
+ spells: string[];
85
+ parts: number[];
86
+ paintkit: number | null;
87
+ quantity: number | null;
88
+ inputs: ExtractedRecipeInput[] | null;
89
+ output: number | null;
90
+ outputQuality: number | null;
91
+ target: number | null;
92
+ crateSeries: number | null;
93
+ }
94
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../libs/tf2-format/src/lib/parsing/bptf/types.ts"],"names":[],"mappings":""}
@@ -1,14 +1,10 @@
1
1
  import { Parser } from '../parser';
2
- import { EconParserSchema, InventoryItem, NumberOrNull } from '../../types';
2
+ import { InventoryItem, NumberOrNull } from '../../types';
3
+ import { EconParserSchema } from '../../schemas';
3
4
  import { DescriptionAttributes, EconItem, ExtractedEconItem, TagAttributes } from './types';
4
5
  declare const enum IdentifiableDescription {
5
6
  Skip = 0,
6
7
  All = 1,
7
- Paint = 1,
8
- Spells = 1,
9
- Parts = 1,
10
- Effect = 1,
11
- Festivized = 3,
12
8
  Killstreaker = 4,
13
9
  Sheen = 5,
14
10
  Killstreak = 6,
@@ -23,10 +19,8 @@ export declare class EconParser extends Parser<EconParserSchema, EconItem, Extra
23
19
  extract(item: EconItem): ExtractedEconItem;
24
20
  parse(raw: ExtractedEconItem): Promise<InventoryItem>;
25
21
  private getPartByScoreType;
26
- private getInputByName;
27
- private fetchInputByName;
28
22
  static getDefindex(item: EconItem): NumberOrNull;
29
- static getKillstreak(descriptions: DescriptionAttributes): number;
23
+ static getKillstreak(name: string, descriptions: DescriptionAttributes): number;
30
24
  static getCrateSeries(tags: TagAttributes, item: EconItem): NumberOrNull;
31
25
  static getTagAttributes(item: EconItem): TagAttributes;
32
26
  static isAustralium(item: EconItem, tags: TagAttributes): boolean;