2025-09-12 16:49:26 -05:00
|
|
|
import { readFile, writeFile } from "fs/promises";
|
|
|
|
|
|
|
|
|
|
const IMPORT = "@protos/auto_legacy_proxy_client";
|
2025-10-13 16:58:16 -05:00
|
|
|
const SOURCE = "../../packages/closed/protos/auto_legacy_proxy_client.proto";
|
|
|
|
|
const TARGET = "../../packages/closed/src/unreal/methodPopulatedProxyClient.ts";
|
2025-09-12 16:49:26 -05:00
|
|
|
|
2025-11-02 18:10:11 -06:00
|
|
|
const requestPattern = /^message (\w+)Request {/gm;
|
2025-09-12 16:49:26 -05:00
|
|
|
const source = await readFile(SOURCE).then((buffer) => buffer.toString());
|
|
|
|
|
const requests = source.matchAll(requestPattern);
|
|
|
|
|
|
|
|
|
|
const imports: string[] = [];
|
2025-11-02 18:10:11 -06:00
|
|
|
const names: string[] = [];
|
2025-09-12 16:49:26 -05:00
|
|
|
|
|
|
|
|
for (const match of requests) {
|
|
|
|
|
const name = match[1];
|
|
|
|
|
|
|
|
|
|
imports.push(`${name}Request`, `${name}Response`);
|
2025-11-02 18:10:11 -06:00
|
|
|
names.push(name);
|
2025-09-12 16:49:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let content = "";
|
|
|
|
|
|
|
|
|
|
content += "import {\n";
|
|
|
|
|
content += imports.map((i) => ` ${i},`).join("\n");
|
|
|
|
|
content += `\n} from "${IMPORT}";\n`;
|
|
|
|
|
|
|
|
|
|
content += 'import { BaseProxyClient } from "./baseProxyClient";\n\n';
|
|
|
|
|
|
|
|
|
|
content +=
|
|
|
|
|
"export abstract class MethodPopulatedProxyClient extends BaseProxyClient {\n";
|
2025-11-02 18:10:11 -06:00
|
|
|
content += names
|
|
|
|
|
.map((name) => {
|
|
|
|
|
return ` ${name}(data: ${name}Request) {
|
2025-09-12 16:49:26 -05:00
|
|
|
return this.request("${name}Request", ${name}Request, data, ${name}Response);
|
|
|
|
|
}\n`;
|
|
|
|
|
})
|
|
|
|
|
.join("");
|
|
|
|
|
content += "}\n";
|
|
|
|
|
|
|
|
|
|
await writeFile(TARGET, content);
|