Add local-first execution authoring support
This commit is contained in:
@@ -122,3 +122,47 @@ test("imperative scaffolds preserve authored wiring; migration sealing is explic
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
test("execution scaffolds route typed handlers by declared effect and target without legacy lifecycle files", async (context) => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "qx-execution-recipe-"));
|
||||
context.after(() => fs.rm(root, { recursive: true, force: true }));
|
||||
await execFile("git", ["-C", root, "init"]);
|
||||
const source = { repository: "https://example.test/execution.git", commit: "a".repeat(40) };
|
||||
const apply = async (
|
||||
command: Parameters<typeof scaffoldRecipe>[1],
|
||||
spec: Partial<Parameters<typeof scaffoldRecipe>[2]>,
|
||||
) => applyStructure(await planStructure(root, await scaffoldRecipe(root, command, { source, ...spec })));
|
||||
await apply("package", {
|
||||
name: "Execution",
|
||||
id: "package:execution",
|
||||
revision: "package:execution@1",
|
||||
template: "typescript-execution",
|
||||
tools: { quixos: source, protocol: source, helpers: source, sdk: source },
|
||||
});
|
||||
for (const file of ["quixos.migrations.json", "src/migrate.ts", "descriptor.quixos-package.txtpb"])
|
||||
await assert.rejects(fs.access(path.join(root, file)));
|
||||
await fs.appendFile(path.join(root, "src/server.ts"), "\n// Preserve authored code\n");
|
||||
const add = (name: string, execution: string) =>
|
||||
apply("function", {
|
||||
name,
|
||||
id: "export:" + name,
|
||||
declaration: `function ${name} id "export:${name}" : unit -> unit execution ${execution};`,
|
||||
});
|
||||
await add("both", "transaction targets [browser, server]");
|
||||
await add("serverOnly", "snapshot targets [server]");
|
||||
await add("asyncWork", "remote");
|
||||
const read = (file: string) => fs.readFile(path.join(root, file), "utf8");
|
||||
assert.match(await read("src/browser.ts"), /"both":/);
|
||||
assert.doesNotMatch(await read("src/browser.ts"), /serverOnly|asyncWork/);
|
||||
assert.match(await read("src/server.ts"), /"serverOnly":/);
|
||||
assert.match(await read("src/server.ts"), /Preserve authored code/);
|
||||
assert.match(await read("src/remote.ts"), /"asyncWork":/);
|
||||
assert.match(await read("src/impl/asyncWork.ts"), /RemoteImplementation/);
|
||||
assert.match(await read("src/impl/both.ts"), /PortableImplementation/);
|
||||
assert.match(await read("flake.nix"), /checkedArtifacts/);
|
||||
assert.match(await read("flake.nix"), /entries.browser/);
|
||||
await assert.rejects(add("both", "transaction targets [browser, server]"), /unique/);
|
||||
await assert.rejects(add("invalid", "snapshot targets [remote]"), /browser\/server/);
|
||||
await assert.rejects(apply("function", { name: "missing", id: "export:missing" }), /explicit execution/);
|
||||
await assert.rejects(apply("migration", { name: "migration", id: "export:migration" }), /not supported/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user