Generate portable capability contexts and checked handler registries
This commit is contained in:
+11
-2
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import { generateTypeScriptBindings } from "./index.js";
|
||||
import { generateTypeScriptBindings, generatePortableTypeScriptBindings } from "./index.js";
|
||||
import path from "node:path";
|
||||
import { reactPlatformTypes } from "./react-platform.js";
|
||||
import { generateReactBindings } from "./react.js";
|
||||
@@ -11,7 +11,16 @@ const main = async () => {
|
||||
throw new Error("usage: quixos-codegen-ts SCHEMA.json PACKAGE_REVISION OUTPUT.ts [OPTIONS.json]");
|
||||
const config = options ? JSON.parse(await readFile(options, "utf8")) : {};
|
||||
const contracts = JSON.parse(await readFile(schema, "utf8"));
|
||||
const generated = generateTypeScriptBindings(contracts, revision, config);
|
||||
if (config.portable && config.react)
|
||||
throw new Error("Portable handlers and React component bindings are separate artifacts");
|
||||
if (config.portable && typeof config.portable.target !== "string")
|
||||
throw new Error("Portable bindings require an explicit target");
|
||||
const generated = config.portable
|
||||
? generatePortableTypeScriptBindings(contracts, revision, {
|
||||
...config.portable,
|
||||
...(config.runtimeModule ? { runtimeModule: config.runtimeModule } : {}),
|
||||
})
|
||||
: generateTypeScriptBindings(contracts, revision, config);
|
||||
await writeFile(output, generated);
|
||||
if (config.react) {
|
||||
await writeFile(path.join(path.dirname(output), "web-studio-react-runtime.d.ts"), reactPlatformTypes);
|
||||
|
||||
Reference in New Issue
Block a user