feat: replace the ssr/client data blocks with apis blocks

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-20 07:59:37 +05:30
co-authored by Claude Opus 5
parent de99a2c2e0
commit 890d6106b3
14 changed files with 135 additions and 1421 deletions
@@ -0,0 +1,33 @@
import { expect, test } from "bun:test";
import { parse } from "../src/index.ts";
test("an ssr data block is rejected and names the replacement", () => {
expect(() =>
parse(`page P {
ssr { api x GET /api/x { return users } }
view { <main>x</main> }
}
`),
).toThrow(/apis/);
});
test("a client data block is rejected and names the replacement", () => {
expect(() =>
parse(`page P {
client { api x GET /api/x { return users } }
view { <main>x</main> }
}
`),
).toThrow(/apis/);
});
test("client state is unaffected", () => {
// Different construct sharing the keyword. It must keep working.
const ast = parse(`page P {
client state { count = 0 }
view { <main>x</main> }
}
`);
expect(ast.states.some((state) => state.name === "count")).toBe(true);
});