@bingosrs/models 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/.idea/bingosrs-models.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/eslint.config.mjs +11 -0
- package/package.json +40 -0
- package/scripts/update-enums.js +67 -0
- package/src/enums/items.ts +14935 -0
- package/src/enums/monsters.ts +3604 -0
- package/src/index.ts +2 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/bingosrs-models.iml" filepath="$PROJECT_DIR$/.idea/bingosrs-models.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 mistereman22
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import { defineConfig } from "eslint/config";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default defineConfig([
|
|
8
|
+
{ files: ["**/*.{js,mjs,cjs,ts,mts,cts}"], plugins: { js }, extends: ["js/recommended"] },
|
|
9
|
+
{ files: ["**/*.{js,mjs,cjs,ts,mts,cts}"], languageOptions: { globals: globals.browser } },
|
|
10
|
+
tseslint.configs.recommended,
|
|
11
|
+
]);
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bingosrs/models",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Auto generated model package for use with BingOSRS",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"node-fetch": "^3.3.2",
|
|
9
|
+
"@eslint/js": "^9.29.0",
|
|
10
|
+
"eslint": "^9.29.0",
|
|
11
|
+
"eslint-config-prettier": "^10.1.5",
|
|
12
|
+
"eslint-plugin-prettier": "^5.5.0",
|
|
13
|
+
"globals": "^16.2.0",
|
|
14
|
+
"prettier": "^3.5.3",
|
|
15
|
+
"typescript": "^5.8.3",
|
|
16
|
+
"typescript-eslint": "^8.34.1"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"lint:fix": "eslint --fix",
|
|
21
|
+
"generate-schema": "quicktype items.json -l schema -o items.schema.json",
|
|
22
|
+
"generate-code": "quicktype -s schema items.schema.json -o items.ts --lang ts"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/mistereman22/bingosrs-models.git"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"bingosrs",
|
|
30
|
+
"osrs",
|
|
31
|
+
"runescape",
|
|
32
|
+
"oldschool"
|
|
33
|
+
],
|
|
34
|
+
"author": "Mistereman22",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/mistereman22/bingosrs-models/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/mistereman22/bingosrs-models#readme"
|
|
40
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import fetch from 'node-fetch';
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
|
|
5
|
+
async function writeEnum(filePath, enumName, dataUrl) {
|
|
6
|
+
const response = await fetch(
|
|
7
|
+
dataUrl,
|
|
8
|
+
{
|
|
9
|
+
headers: {
|
|
10
|
+
'User-Agent': 'bingosrs-models - @mistereman22 on Discord'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
)
|
|
14
|
+
const data = await response.json()
|
|
15
|
+
let enumContent = `export enum ${enumName} {\n`;
|
|
16
|
+
|
|
17
|
+
const nameCounts = {};
|
|
18
|
+
|
|
19
|
+
for (const key in data) {
|
|
20
|
+
if (data.hasOwnProperty(key)) {
|
|
21
|
+
const id = parseInt(key, 10);
|
|
22
|
+
let name = data[key].name;
|
|
23
|
+
|
|
24
|
+
// There are empty item names for some reason. Including them just in case they have any future use
|
|
25
|
+
if (name.length === 0) {
|
|
26
|
+
name = "UNKNOWN_" + id
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let enumMemberName = name
|
|
30
|
+
.toUpperCase()
|
|
31
|
+
.replace(/ /g, '_')
|
|
32
|
+
.replace(/[^a-zA-Z0-9_]/g, '')
|
|
33
|
+
.replace(/^_|_$/g, '');
|
|
34
|
+
|
|
35
|
+
// Prepend underscore if name starts with a number
|
|
36
|
+
if (/^\d/.test(enumMemberName)) {
|
|
37
|
+
enumMemberName = `_${enumMemberName}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (nameCounts[enumMemberName]) {
|
|
41
|
+
nameCounts[enumMemberName]++;
|
|
42
|
+
// Double underscore to avoid conflict with items that already end in number (e.g. Ancient Page 2)
|
|
43
|
+
enumMemberName = `${enumMemberName}__${nameCounts[enumMemberName]}`;
|
|
44
|
+
} else {
|
|
45
|
+
nameCounts[enumMemberName] = 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
enumContent += ` ${enumMemberName} = ${id},\n`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
enumContent += '}\n';
|
|
53
|
+
|
|
54
|
+
const enumDir = path.dirname(filePath);
|
|
55
|
+
if (!fs.existsSync(enumDir)) {
|
|
56
|
+
fs.mkdirSync(enumDir, { recursive: true });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
fs.writeFileSync(filePath, enumContent, 'utf8');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function main() {
|
|
63
|
+
await writeEnum('./src/enums/items.ts', 'EItem', 'https://raw.githubusercontent.com/DayV-git/osrsreboxed-db/data/docs/items-summary.json')
|
|
64
|
+
await writeEnum('./src/enums/monsters.ts', 'EMonster', 'https://raw.githubusercontent.com/DayV-git/osrsreboxed-db/data/docs/monsters-complete.json')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
await main()
|