refactor(dify-builder): generate contract TS into @dify/contracts/dify-builder

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Charles YaoandClaude Opus 4.8 committed 2026-08-31 23:34:45 -07:00
1 parent 9fe2e2a3fa
commit cad5919220
4 files changed
+76 -2

No files matched your search

+1 -1
View File
@@ -243,7 +243,7 @@ def main() -> None:
repo_root = next(p for p in Path(__file__).parents if (p / "web").is_dir() and (p / "api").is_dir())
schema_path = Path(__file__).with_name("contract_schema.json")
ts_path = repo_root / "web" / "app" / "components" / "dify-builder" / "contract" / "types.ts"
ts_path = repo_root / "packages" / "contracts" / "generated" / "dify-builder" / "types.ts"
schema_path.write_text(json.dumps(schema, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
ts_path.parent.mkdir(parents=True, exist_ok=True)
@@ -255,7 +255,7 @@ def test_schema_in_lockstep():
schema, ts = contract_gen.generate()
root = next(p for p in Path(__file__).parents if (p / "web").is_dir() and (p / "api").is_dir())
checked_json = (root / "api/core/dify_builder/contract_schema.json").read_text()
checked_ts = (root / "web/app/components/dify-builder/contract/types.ts").read_text()
checked_ts = (root / "packages/contracts/generated/dify-builder/types.ts").read_text()
regen_hint = "run: uv run --directory api python -m core.dify_builder.contract_gen"
assert json.dumps(schema, indent=2, ensure_ascii=False) + "\n" == checked_json, regen_hint
assert ts == checked_ts, regen_hint