mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
c70aee247e
* refactor(scripts): migrate JavaScript tools to TypeScript * fix(ci): keep changed-scope preflight zero-install * fix(ci): preserve zero-install script owners * fix(ci): complete script migration follow-through * fix(release): keep stable closeout zero-install * fix(scripts): preserve standalone execution boundaries * fix(scripts): repair standalone loader boundaries * fix(scripts): normalize gateway observation ids * fix(scripts): keep Docker packager standalone * test(scripts): preserve rebase cleanup helpers * test(sessions): use tracked temp directory
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
export const STATE_SCHEMA_INLINE_PLUGIN_NAME = "openclaw:inline-state-schemas";
|
|
|
|
const STATE_SCHEMA_MODULES = [
|
|
{
|
|
modulePath: "src/state/openclaw-state-schema.ts",
|
|
schemaPath: "src/state/openclaw-state-schema.sql",
|
|
exportName: "OPENCLAW_STATE_SCHEMA_SQL",
|
|
},
|
|
{
|
|
modulePath: "src/state/openclaw-agent-schema.ts",
|
|
schemaPath: "src/state/openclaw-agent-schema.sql",
|
|
exportName: "OPENCLAW_AGENT_SCHEMA_SQL",
|
|
},
|
|
] as const;
|
|
|
|
/** Inline canonical schema bytes so bundled consumers need no SQL asset. */
|
|
export function createStateSchemaInlinePlugin(rootDir = process.cwd()) {
|
|
const schemasByModulePath = new Map(
|
|
STATE_SCHEMA_MODULES.map((schema) => [path.resolve(rootDir, schema.modulePath), schema]),
|
|
);
|
|
|
|
return {
|
|
name: STATE_SCHEMA_INLINE_PLUGIN_NAME,
|
|
load(this: { addWatchFile(id: string): void }, id: string) {
|
|
const schema = schemasByModulePath.get(path.resolve(id));
|
|
if (!schema) {
|
|
return null;
|
|
}
|
|
const schemaPath = path.resolve(rootDir, schema.schemaPath);
|
|
this.addWatchFile(schemaPath);
|
|
return {
|
|
code: `export const ${schema.exportName} = ${JSON.stringify(fs.readFileSync(schemaPath, "utf8"))};\n`,
|
|
moduleType: "js" as const,
|
|
};
|
|
},
|
|
};
|
|
}
|