@hasagi/schema 0.6.3 → 0.6.4
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/openapi/openapi-schema.js +2 -2
- package/overrides.d.ts +1 -0
- package/overrides.js +5 -0
- package/package.json +2 -2
- package/util.d.ts +1 -1
- package/util.js +6 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatFieldName, formatForArrayLabel,
|
|
1
|
+
import { formatFieldName, formatForArrayLabel, getTypeScriptName } from "../util.js";
|
|
2
2
|
const DEFAULT_TYPES = `export type LCUEndpoint<Method extends HttpMethod, Path extends EndpointsWithMethod<Method>> = (...args: [...(Path extends keyof LCUEndpoints ? Method extends keyof LCUEndpoints[Path] ? "path" extends keyof LCUEndpoints[Path][Method] ? LCUEndpoints[Path][Method]["path"] extends never ? [] : LCUEndpoints[Path][Method]["path"] : [] : [] : []), ...(LCUEndpointBodyType<Method, Path> extends never ? (LCUEndpointParams<Method, Path> extends never ? [] : {} extends LCUEndpointParams<Method, Path> ? [data?: LCUEndpointParams<Method, Path>] : [data: LCUEndpointParams<Method, Path>]) : [data: LCUEndpointBodyType<Method, Path>])]) => Promise<LCUEndpointResponseType<Method, Path>>
|
|
3
3
|
export type LCUEndpointResponseType<Method extends string, Path extends string> = Path extends keyof LCUEndpoints ? Method extends keyof LCUEndpoints[Path] ? "response" extends keyof LCUEndpoints[Path][Method] ? LCUEndpoints[Path][Method]["response"] : unknown : unknown : unknown;
|
|
4
4
|
export type LCUEndpointBodyType<Method extends string, Path extends string> = Path extends keyof LCUEndpoints ? Method extends keyof LCUEndpoints[Path] ? "body" extends keyof LCUEndpoints[Path][Method] ? LCUEndpoints[Path][Method]["body"] : unknown : unknown : unknown;
|
|
@@ -31,7 +31,7 @@ export default class OpenAPISchema {
|
|
|
31
31
|
if (this.components?.schemas === undefined)
|
|
32
32
|
return [];
|
|
33
33
|
return Object.entries(this.components.schemas).map(([name, schema]) => {
|
|
34
|
-
name =
|
|
34
|
+
name = getTypeScriptName(name);
|
|
35
35
|
if (TYPE_OVERRIDES[name] && TYPE_OVERRIDES[name].definition)
|
|
36
36
|
return `export ${TYPE_OVERRIDES[TYPE_OVERRIDES[name].rename ?? name].definition}`.replaceAll("{{namespace}}", namespace !== undefined ? `${namespace}.` : "");
|
|
37
37
|
if ("$ref" in schema) {
|
package/overrides.d.ts
CHANGED
package/overrides.js
CHANGED
|
@@ -59,3 +59,8 @@ export const EXTENDED_HELP_FUNCTION_OVERRIDES = {
|
|
|
59
59
|
tags: ["riotclient"]
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
+
export const TYPESCRIPT_TYPE_NAME_OVERRIDES = {
|
|
63
|
+
"LolMissionsCapMissionSeries": "LolMissionsCAPMissionSeries",
|
|
64
|
+
"LolObjectivesCapMissionSeries": "LolObjectivesCAPMissionSeries",
|
|
65
|
+
"LolTftEventCapMissionSeries": "LolTftEventCAPMissionSeries"
|
|
66
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasagi/schema",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"hasagi"
|
|
6
6
|
],
|
|
7
7
|
"author": "dysolix",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@hasagi/core": "^0.6.
|
|
10
|
+
"@hasagi/core": "^0.6.3",
|
|
11
11
|
"axios": "^1.7.9"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
package/util.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export declare function getType(t: {
|
|
|
5
5
|
elementType: string;
|
|
6
6
|
} | string, namespace?: string): string;
|
|
7
7
|
export declare function formatForArrayLabel(str: string): string;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function getTypeScriptName(input: string): string;
|
package/util.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "fs/promises";
|
|
2
|
+
import { TYPESCRIPT_TYPE_NAME_OVERRIDES } from "./overrides";
|
|
2
3
|
function requiresQuotes(fieldName) {
|
|
3
4
|
return fieldName.includes("-") || /\d/.test(fieldName);
|
|
4
5
|
}
|
|
@@ -48,6 +49,9 @@ export function formatForArrayLabel(str) {
|
|
|
48
49
|
function kebabCaseToCamelCase(str) {
|
|
49
50
|
return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
50
51
|
}
|
|
51
|
-
export function
|
|
52
|
-
|
|
52
|
+
export function getTypeScriptName(input) {
|
|
53
|
+
input = input.replaceAll("-", "_");
|
|
54
|
+
if (TYPESCRIPT_TYPE_NAME_OVERRIDES[input])
|
|
55
|
+
input = TYPESCRIPT_TYPE_NAME_OVERRIDES[input];
|
|
56
|
+
return input;
|
|
53
57
|
}
|