Skip to content

Commit

Permalink
WIP: Autogenerate types from official documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymerNiklasistanonym committed Apr 27, 2023
1 parent 1b55e99 commit c17ed30
Show file tree
Hide file tree
Showing 327 changed files with 171,425 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,4 @@ pages/example_output
examples/**/package-lock.json
# Ignore certain example files
examples/**/node_modules
scripts/cache.html
124 changes: 124 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"madge": "^6.0.0",
"mocha": "^10.2.0",
"moment": "^2.29.4",
"node-html-parser": "^6.1.5",
"nyc": "^15.1.0",
"prettier": "^2.8.8",
"rimraf": "^5.0.0",
Expand All @@ -36,14 +37,15 @@
"scripts": {
"build": "tsc",
"build:check": "tsc --noEmit",
"create:osuApiTypes": "ts-node --project tsconfig.eslint.json --esm scripts/createOsuApiTypes.mts",
"docs": "typedoc --tsconfig tsconfig.json",
"docs:createPagesExampleOutput": "ts-node --project tsconfig.json --esm pages/create_pages_example_output.mts",
"format": "prettier --check examples src test",
"format:fix": "prettier --write examples pages src test",
"lint": "eslint pages src test",
"format:fix": "prettier --write examples pages scripts src test",
"lint": "eslint pages scripts src test",
"lint:circular": "madge --circular lib/index.mjs",
"lint:exports": "ts-unused-exports tsconfig.json --showLineNumber",
"lint:fix": "eslint --fix pages src test",
"lint:fix": "eslint --fix pages scripts src test",
"prebuild": "rimraf lib",
"test": "mocha -- test/**/**/*.test.mts test/**/*.test.mts test/*.test.mts",
"test:no-refresh-token": "mocha --invert --fgrep refresh-token -- test/**/**/*.test.mts test/**/*.test.mts test/*.test.mts",
Expand Down
26 changes: 26 additions & 0 deletions scripts/autogen/checkGeneric.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Package imports
import { expect } from "chai"

export interface DefaultCheckResponseOptions {
doNotCheckForUncheckedKeys?: boolean
}

export const genericCheckObjectForUncheckedKeys = <DATA_TYPE extends object>(
input: Readonly<DATA_TYPE>,
checkedKeys: ReadonlyArray<string>,
options?: DefaultCheckResponseOptions,
): ReadonlyArray<string> => {
if (options?.doNotCheckForUncheckedKeys) {
return checkedKeys
}
for (const [key, value] of Object.entries(input)) {
if (!checkedKeys.includes(key) && value !== undefined) {
expect.fail(
`Found unchecked key '${key}': '${JSON.stringify(
value,
)}' (${JSON.stringify(input)})`,
)
}
}
return checkedKeys
}
9 changes: 9 additions & 0 deletions scripts/autogen/generateTypescriptMochaTest.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Type imports
import type { OsuApiV2Types } from "./parseTypes.mjs"

export const generateTypescriptMochaTestString = (
type: Readonly<OsuApiV2Types>,
typeFilePath: ReadonlyMap<string, string>,
): string => {
return "TODO" + type.name + (typeFilePath.get(type.name) ?? "NOT FOUND!")
}
Loading

0 comments on commit c17ed30

Please sign in to comment.