Merge pull request 'API: types schema improve typescript performance' (#2022) from hsjobeki/clan-core:hsjobeki-main into main
This commit is contained in:
@@ -7,10 +7,7 @@ from clan_cli.api import API
|
|||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
schema = API.to_json_schema()
|
schema = API.to_json_schema()
|
||||||
print(
|
print(f"""{json.dumps(schema, indent=2)}""")
|
||||||
f"""export const schema = {json.dumps(schema, indent=2)} as const;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ API.register(open_file)
|
|||||||
"properties": {},
|
"properties": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err_type = None
|
||||||
for name, func in self._registry.items():
|
for name, func in self._registry.items():
|
||||||
hints = get_type_hints(func)
|
hints = get_type_hints(func)
|
||||||
|
|
||||||
@@ -175,6 +176,15 @@ API.register(open_file)
|
|||||||
|
|
||||||
return_type = serialized_hints.pop("return")
|
return_type = serialized_hints.pop("return")
|
||||||
|
|
||||||
|
if err_type is None:
|
||||||
|
err_type = next(
|
||||||
|
t
|
||||||
|
for t in return_type["oneOf"]
|
||||||
|
if ("error" in t["properties"]["status"]["enum"])
|
||||||
|
)
|
||||||
|
|
||||||
|
return_type["oneOf"][1] = {"$ref": "#/$defs/error"}
|
||||||
|
|
||||||
sig = signature(func)
|
sig = signature(func)
|
||||||
required_args = []
|
required_args = []
|
||||||
for n, param in sig.parameters.items():
|
for n, param in sig.parameters.items():
|
||||||
@@ -196,6 +206,8 @@ API.register(open_file)
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
api_schema["$defs"] = {"error": err_type}
|
||||||
|
|
||||||
return api_schema
|
return api_schema
|
||||||
|
|
||||||
def get_method_argtype(self, method_name: str, arg_name: str) -> Any:
|
def get_method_argtype(self, method_name: str, arg_name: str) -> Any:
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ def type_to_dict(
|
|||||||
required.add(pn)
|
required.add(pn)
|
||||||
|
|
||||||
elif pv.get("oneOf") is not None:
|
elif pv.get("oneOf") is not None:
|
||||||
if "null" not in [i["type"] for i in pv.get("oneOf", [])]:
|
if "null" not in [i.get("type") for i in pv.get("oneOf", [])]:
|
||||||
required.add(pn)
|
required.add(pn)
|
||||||
|
|
||||||
required_fields = {
|
required_fields = {
|
||||||
|
|||||||
@@ -6,7 +6,11 @@
|
|||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
perSystem =
|
perSystem =
|
||||||
{ self', pkgs, ... }:
|
{
|
||||||
|
self',
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
flakeLock = lib.importJSON (self + /flake.lock);
|
flakeLock = lib.importJSON (self + /flake.lock);
|
||||||
flakeInputs = builtins.removeAttrs inputs [ "self" ];
|
flakeInputs = builtins.removeAttrs inputs [ "self" ];
|
||||||
@@ -63,7 +67,6 @@
|
|||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
|
||||||
# TODO: see postFixup clan-cli/default.nix:L188
|
# TODO: see postFixup clan-cli/default.nix:L188
|
||||||
pkgs.python3
|
pkgs.python3
|
||||||
self'.packages.clan-cli.propagatedBuildInputs
|
self'.packages.clan-cli.propagatedBuildInputs
|
||||||
@@ -84,17 +87,28 @@
|
|||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs.python3
|
pkgs.python3
|
||||||
|
self'.packages.json2ts
|
||||||
# TODO: see postFixup clan-cli/default.nix:L188
|
# TODO: see postFixup clan-cli/default.nix:L188
|
||||||
self'.packages.clan-cli.propagatedBuildInputs
|
self'.packages.clan-cli.propagatedBuildInputs
|
||||||
];
|
];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
${self'.packages.classgen}/bin/classgen ${self'.packages.inventory-schema}/schema.json ./clan_cli/inventory/classes.py
|
${self'.packages.classgen}/bin/classgen ${self'.packages.inventory-schema}/schema.json ./clan_cli/inventory/classes.py
|
||||||
|
mkdir -p $out
|
||||||
python api.py > $out
|
python api.py > $out/API.json
|
||||||
|
${self'.packages.json2ts}/bin/json2ts --input $out/API.json > $out/API.ts
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
json2ts = pkgs.buildNpmPackage {
|
||||||
|
name = "json2ts";
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "bcherny";
|
||||||
|
repo = "json-schema-to-typescript";
|
||||||
|
rev = "118d6a8e7a5a9397d1d390ce297f127ae674a623";
|
||||||
|
hash = "sha256-ldAFfw3E0A0lIJyDSsshgPRPR7OmV/FncPsDhC3waT8=";
|
||||||
|
};
|
||||||
|
npmDepsHash = "sha256-kLKau4SBxI9bMAd7X8/FQfCza2sYl/+0bg2LQcOQIJo=";
|
||||||
|
};
|
||||||
|
|
||||||
default = self'.packages.clan-cli;
|
default = self'.packages.clan-cli;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import { JSONSchemaFaker } from "json-schema-faker";
|
|
||||||
import { schema } from "./api/index";
|
|
||||||
import { OperationNames } from "./src/api";
|
|
||||||
|
|
||||||
const faker = JSONSchemaFaker;
|
|
||||||
|
|
||||||
faker.option({
|
|
||||||
alwaysFakeOptionals: true,
|
|
||||||
useExamplesValue: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const getFakeResponse = (method: OperationNames, data: any) => {
|
|
||||||
const fakeData = faker.generate(schema.properties[method].properties.return);
|
|
||||||
const { op_key } = data;
|
|
||||||
if (method === "open_file") {
|
|
||||||
return {
|
|
||||||
status: "success",
|
|
||||||
data: "/home/johannes/git/clan-core",
|
|
||||||
op_key,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-expect-error: fakeData is guaranteed to always be some object
|
|
||||||
return { ...fakeData, op_key };
|
|
||||||
};
|
|
||||||
|
|
||||||
export { getFakeResponse };
|
|
||||||
135
pkgs/webview-ui/app/package-lock.json
generated
135
pkgs/webview-ui/app/package-lock.json
generated
@@ -31,8 +31,6 @@
|
|||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-tailwindcss": "^3.17.0",
|
"eslint-plugin-tailwindcss": "^3.17.0",
|
||||||
"jsdom": "^24.1.0",
|
"jsdom": "^24.1.0",
|
||||||
"json-schema-faker": "^0.5.6",
|
|
||||||
"json-schema-to-ts": "^3.1.0",
|
|
||||||
"postcss": "^8.4.38",
|
"postcss": "^8.4.38",
|
||||||
"postcss-url": "^10.1.3",
|
"postcss-url": "^10.1.3",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
@@ -357,18 +355,6 @@
|
|||||||
"@babel/core": "^7.0.0-0"
|
"@babel/core": "^7.0.0-0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@babel/runtime": {
|
|
||||||
"version": "7.24.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.5.tgz",
|
|
||||||
"integrity": "sha512-Nms86NXrsaeU9vbBJKni6gXiEXZ4CVpYVzEjDH9Sb8vmZ3UljyA1GSOJl/6LGPO8EHLuSF9H+IxNXHPX8QHJ4g==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"regenerator-runtime": "^0.14.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6.9.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@babel/template": {
|
"node_modules/@babel/template": {
|
||||||
"version": "7.24.0",
|
"version": "7.24.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.24.0.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.24.0.tgz",
|
||||||
@@ -2370,12 +2356,6 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/call-me-maybe": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz",
|
|
||||||
"integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/callsites": {
|
"node_modules/callsites": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
|
||||||
@@ -3118,19 +3098,6 @@
|
|||||||
"url": "https://opencollective.com/eslint"
|
"url": "https://opencollective.com/eslint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/esprima": {
|
|
||||||
"version": "4.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
|
||||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
|
||||||
"dev": true,
|
|
||||||
"bin": {
|
|
||||||
"esparse": "bin/esparse.js",
|
|
||||||
"esvalidate": "bin/esvalidate.js"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/esquery": {
|
"node_modules/esquery": {
|
||||||
"version": "1.5.0",
|
"version": "1.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz",
|
||||||
@@ -3341,12 +3308,6 @@
|
|||||||
"node": ">= 6"
|
"node": ">= 6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/format-util": {
|
|
||||||
"version": "1.0.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/format-util/-/format-util-1.0.5.tgz",
|
|
||||||
"integrity": "sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/fraction.js": {
|
"node_modules/fraction.js": {
|
||||||
"version": "4.3.7",
|
"version": "4.3.7",
|
||||||
"resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz",
|
"resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz",
|
||||||
@@ -3850,66 +3811,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
|
||||||
"integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
|
"integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
|
||||||
},
|
},
|
||||||
"node_modules/json-schema-faker": {
|
|
||||||
"version": "0.5.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/json-schema-faker/-/json-schema-faker-0.5.6.tgz",
|
|
||||||
"integrity": "sha512-u/cFC26/GDxh2vPiAC8B8xVvpXAW+QYtG2mijEbKrimCk8IHtiwQBjCE8TwvowdhALWq9IcdIWZ+/8ocXvdL3Q==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"json-schema-ref-parser": "^6.1.0",
|
|
||||||
"jsonpath-plus": "^7.2.0"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"jsf": "bin/gen.cjs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/json-schema-ref-parser": {
|
|
||||||
"version": "6.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-6.1.0.tgz",
|
|
||||||
"integrity": "sha512-pXe9H1m6IgIpXmE5JSb8epilNTGsmTb2iPohAXpOdhqGFbQjNeHHsZxU+C8w6T81GZxSPFLeUoqDJmzxx5IGuw==",
|
|
||||||
"deprecated": "Please switch to @apidevtools/json-schema-ref-parser",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"call-me-maybe": "^1.0.1",
|
|
||||||
"js-yaml": "^3.12.1",
|
|
||||||
"ono": "^4.0.11"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/json-schema-ref-parser/node_modules/argparse": {
|
|
||||||
"version": "1.0.10",
|
|
||||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
|
||||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"sprintf-js": "~1.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/json-schema-ref-parser/node_modules/js-yaml": {
|
|
||||||
"version": "3.14.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
|
||||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"argparse": "^1.0.7",
|
|
||||||
"esprima": "^4.0.0"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"js-yaml": "bin/js-yaml.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/json-schema-to-ts": {
|
|
||||||
"version": "3.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-3.1.0.tgz",
|
|
||||||
"integrity": "sha512-UeVN/ery4/JeXI8h4rM8yZPxsH+KqPi/84qFxHfTGHZnWnK9D0UU9ZGYO+6XAaJLqCWMiks+ARuFOKAiSxJCHA==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@babel/runtime": "^7.18.3",
|
|
||||||
"ts-algebra": "^2.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=16"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/json-schema-traverse": {
|
"node_modules/json-schema-traverse": {
|
||||||
"version": "0.4.1",
|
"version": "0.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
|
||||||
@@ -3932,15 +3833,6 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/jsonpath-plus": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-zBfiUPM5nD0YZSBT/o/fbCUlCcepMIdP0CJZxM1+KgA4f2T206f6VAg9e7mX35+KlMaIc5qXW34f3BnwJ3w+RA==",
|
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/keyv": {
|
"node_modules/keyv": {
|
||||||
"version": "4.5.4",
|
"version": "4.5.4",
|
||||||
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
|
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
|
||||||
@@ -4397,15 +4289,6 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ono": {
|
|
||||||
"version": "4.0.11",
|
|
||||||
"resolved": "https://registry.npmjs.org/ono/-/ono-4.0.11.tgz",
|
|
||||||
"integrity": "sha512-jQ31cORBFE6td25deYeD80wxKBMj+zBmHTrVxnc6CKhx8gho6ipmWM5zj/oeoqioZ99yqBls9Z/9Nss7J26G2g==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"format-util": "^1.0.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/optionator": {
|
"node_modules/optionator": {
|
||||||
"version": "0.9.4",
|
"version": "0.9.4",
|
||||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
|
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
|
||||||
@@ -4965,12 +4848,6 @@
|
|||||||
"node": ">=8.10.0"
|
"node": ">=8.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/regenerator-runtime": {
|
|
||||||
"version": "0.14.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
|
|
||||||
"integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/requires-port": {
|
"node_modules/requires-port": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
||||||
@@ -5325,12 +5202,6 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/sprintf-js": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/stackback": {
|
"node_modules/stackback": {
|
||||||
"version": "0.0.2",
|
"version": "0.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",
|
||||||
@@ -5750,12 +5621,6 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ts-algebra": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ts-algebra/-/ts-algebra-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/ts-api-utils": {
|
"node_modules/ts-api-utils": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz",
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-tailwindcss": "^3.17.0",
|
"eslint-plugin-tailwindcss": "^3.17.0",
|
||||||
"jsdom": "^24.1.0",
|
"jsdom": "^24.1.0",
|
||||||
"json-schema-faker": "^0.5.6",
|
|
||||||
"json-schema-to-ts": "^3.1.0",
|
|
||||||
"postcss": "^8.4.38",
|
"postcss": "^8.4.38",
|
||||||
"postcss-url": "^10.1.3",
|
"postcss-url": "^10.1.3",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import { FromSchema } from "json-schema-to-ts";
|
import schema from "@/api/API.json" assert { type: "json" };
|
||||||
import { schema } from "@/api";
|
import { API } from "@/api/API";
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
|
|
||||||
export type API = FromSchema<typeof schema>;
|
|
||||||
|
|
||||||
export type OperationNames = keyof API;
|
export type OperationNames = keyof API;
|
||||||
export type OperationArgs<T extends OperationNames> = API[T]["arguments"];
|
export type OperationArgs<T extends OperationNames> = API[T]["arguments"];
|
||||||
export type OperationResponse<T extends OperationNames> = API[T]["return"];
|
export type OperationResponse<T extends OperationNames> = API[T]["return"];
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
preBuild = ''
|
preBuild = ''
|
||||||
mkdir -p api
|
mkdir -p api
|
||||||
cat ${config.packages.clan-ts-api} > api/index.ts
|
cp -r ${config.packages.clan-ts-api}/* api
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
devShells.webview-ui = pkgs.mkShell {
|
devShells.webview-ui = pkgs.mkShell {
|
||||||
@@ -50,7 +50,8 @@
|
|||||||
|
|
||||||
|
|
||||||
mkdir -p ./app/api
|
mkdir -p ./app/api
|
||||||
cat ${config.packages.clan-ts-api} > ./app/api/index.ts
|
cp -r ${config.packages.clan-ts-api}/* app/api
|
||||||
|
chmod -R +w app/api
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user