Skip to content

Commit c6f6794

Browse files
committed
wip: changes
1 parent 30c4ddb commit c6f6794

25 files changed

+1054
-788
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
on:
22
repository_dispatch:
3-
types: [spec_release]
3+
types: [release]
44
push:
55
branches:
66
- main
@@ -21,9 +21,6 @@ jobs:
2121
version: 10
2222
run_install: false
2323

24-
- name: Install yq via apt
25-
run: sudo apt install -y yq
26-
2724
- name: Install Node.js
2825
uses: actions/setup-node@v4
2926
with:

example/package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"name": "example",
3-
"version": "1.0.0",
4-
"description": "",
5-
"main": "index.js",
6-
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8-
},
9-
"keywords": [],
10-
"author": "",
11-
"license": "ISC",
12-
"dependencies": {
13-
"dotenv": "^16.5.0",
14-
"enquirer": "^2.4.1",
15-
"keyv": "^5.3.4",
16-
"keyv-file": "^5.1.2",
17-
"prompts": "^2.4.2",
18-
"vrchat": "^1.19.4"
19-
},
20-
"devDependencies": {
21-
"@types/prompts": "^2.4.9",
22-
"typescript": "^5.8.3"
23-
}
24-
}
2+
"name": "example",
3+
"version": "1.0.0",
4+
"description": "",
5+
"author": "",
6+
"license": "ISC",
7+
"keywords": [],
8+
"main": "index.js",
9+
"scripts": {
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"dependencies": {
13+
"dotenv": "^16.5.0",
14+
"enquirer": "^2.4.1",
15+
"keyv": "^5.3.4",
16+
"keyv-file": "^5.1.2",
17+
"prompts": "^2.4.2",
18+
"vrchat": "workspace:*"
19+
},
20+
"devDependencies": {
21+
"@types/prompts": "^2.4.9",
22+
"typescript": "^5.8.3"
23+
}
24+
}

example/src/default.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const vrchat = new VRChat({
88
* When using the VRChat API, you must provide an application name, version, and contact information.
99
* This is used to identify your application to VRChat, and to provide support if needed.
1010
*/
11+
verbose: true,
1112
application: {
1213
name: "Example",
1314
version: "1.5.1",
@@ -82,6 +83,7 @@ const vrchat = new VRChat({
8283
});
8384
});
8485

86+
console.log(user);
8587
console.log(`Logged in as ${user.displayName} (id: ${user.id}).`);
8688

8789
/**

openapi-ts.config.ts

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,6 @@
1-
import type { Plugin } from "@hey-api/openapi-ts";
21
import { defineConfig } from "@hey-api/openapi-ts";
3-
import ts from "typescript";
42

5-
const customPlugin: Plugin.Config<{ name: "vrchat/custom-plugin" }> = {
6-
name: "vrchat/custom-plugin",
7-
_handler: ({ context }) => {
8-
const typesFile = context.file({ id: "types" })!;
9-
10-
context.subscribe("after", () => {
11-
const items = (typesFile as any)._items as Array<ts.Node>;
12-
13-
// type _Error = { ... }
14-
// ->
15-
// import { VRChatError } from "../error";
16-
// type _Error = VRChatError;
17-
18-
const errorTypeName = "_Error";
19-
const errorTypeIndex = items.findIndex((item: ts.Node) => ts.isTypeAliasDeclaration(item) && item.name.text === errorTypeName);
20-
if (errorTypeIndex === -1) throw new Error("Could not find error type definition");
21-
22-
const { name: errorImport } = typesFile.import({ module: "../error", name: "VRChatError", asType: true });
23-
const errorImportIdentifier = ts.factory.createIdentifier(errorImport);
24-
25-
items[errorTypeIndex] = ts.factory.createTypeAliasDeclaration(
26-
undefined,
27-
ts.factory.createIdentifier(errorTypeName),
28-
undefined,
29-
ts.factory.createTypeReferenceNode(
30-
errorImportIdentifier,
31-
undefined
32-
)
33-
);
34-
});
35-
},
36-
_handlerLegacy: () => { },
37-
};
3+
import { errorPlugin } from "./plugins/error";
384

395
export default defineConfig({
406
input: "./openapi.yaml",
@@ -43,14 +9,18 @@ export default defineConfig({
439
{
4410
name: "@hey-api/typescript",
4511
exportFromIndex: false,
12+
requests: "{{name}}",
13+
enums: {
14+
case: "camelCase"
15+
}
4616
},
4717
{
4818
name: "@hey-api/client-fetch",
49-
exportFromIndex: false,
19+
exportFromIndex: false
5020
},
5121
{
5222
name: "@hey-api/transformers",
53-
exportFromIndex: false,
23+
exportFromIndex: false
5424
},
5525
{
5626
name: "@hey-api/sdk",
@@ -61,6 +31,6 @@ export default defineConfig({
6131
transformer: true,
6232
classNameBuilder: () => "VRChatInternal",
6333
},
64-
customPlugin as any
34+
errorPlugin()
6535
],
6636
});

package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "vrchat",
3-
"version": "0.0.0-next.0",
3+
"displayName": "VRChat.js",
4+
"version": "0.0.0",
45
"description": "",
56
"type": "commonjs",
67
"types": "dist/index.d.ts",
@@ -34,22 +35,22 @@
3435
"author": "",
3536
"license": "MIT",
3637
"dependencies": {
37-
"cacheable": "^1.10.0",
38-
"debug": "^4.4.1",
38+
"cacheable": "^1.10.4",
39+
"debug": "^4.4.3",
3940
"isomorphic-ws": "^5.0.0",
40-
"keyv": "^5.3.4",
41-
"@hey-api/client-fetch": "^0.13.0",
42-
"totp-generator": "^1.0.0",
41+
"keyv": "^5.5.5",
42+
"totp-generator": "^2.0.0",
4343
"ws": "^8.18.3"
4444
},
4545
"devDependencies": {
4646
"@ariesclark/eslint-config": "^3.1.1",
47-
"@hey-api/openapi-ts": "^0.72.1",
47+
"@hey-api/openapi-ts": "^0.88.0",
4848
"@types/debug": "^4.1.12",
49-
"@types/node": "^24.0.3",
50-
"eslint": "^9.29.0",
51-
"tsup": "^8.5.0",
49+
"@types/node": "^24.10.1",
50+
"bun-plugin-dts": "^0.3.0",
51+
"eslint": "^9.39.1",
52+
"tsup": "^8.5.1",
5253
"typed-emitter": "^2.1.0",
53-
"typescript": "^5.8.3"
54+
"typescript": "^5.9.3"
5455
}
5556
}

plugins/error.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { $, definePluginConfig } from "@hey-api/openapi-ts";
2+
3+
export const errorPlugin = definePluginConfig({
4+
name: "vrchat/error",
5+
config: {},
6+
dependencies: ["@hey-api/typescript"],
7+
handler: ({ plugin }) => {
8+
const symbol = plugin.querySymbol({ resourceId: "#/components/schemas/Error" });
9+
10+
plugin.setSymbolValue(
11+
symbol,
12+
$.type
13+
.alias(symbol.placeholder)
14+
.export(symbol.exported)
15+
.type(plugin.registerSymbol({
16+
external: "../error",
17+
name: "VRChatError",
18+
}).placeholder)
19+
);
20+
}
21+
});

0 commit comments

Comments
 (0)