feat: add module runtime lifecycle
CI / verify (push) Successful in 2m14s
CI / infrastructure-smoke (push) Failing after 1m36s

This commit is contained in:
ekklesia
2026-07-12 22:49:51 -05:00
parent 57552a21a4
commit 7b448d8706
28 changed files with 1382 additions and 203 deletions
+27 -3
View File
@@ -1,14 +1,38 @@
import { readFile } from "node:fs/promises";
import { defineModule, type ModuleManifestInput } from "@ekklesia/module-sdk";
import {
type CapabilityId,
parseModuleManifest,
type RegisteredCapability,
} from "@ekklesia/module-sdk";
import { describe, expect, it } from "vitest";
import moduleRuntime, { recordsCapability } from "../src/server/index.js";
describe("module template", () => {
it("ships a valid backend-only manifest", async () => {
const manifestUrl = new URL("../ekklesia.module.json", import.meta.url);
const manifestInput = JSON.parse(await readFile(manifestUrl, "utf8")) as ModuleManifestInput;
const manifest = defineModule(manifestInput);
const manifestInput = JSON.parse(await readFile(manifestUrl, "utf8")) as unknown;
const manifest = parseModuleManifest(manifestInput);
expect(manifest.id).toBe("example");
expect(manifest.capabilities).toEqual([{ id: "example.records", version: "1.0.0" }]);
expect(manifest.storage.buckets.map((bucket) => bucket.id)).toEqual(["records"]);
});
it("exports the typed runtime definition used by the compiled server entrypoint", async () => {
const provided = new Map<CapabilityId, unknown>();
await moduleRuntime.register?.({
capabilities: {
provide(capabilityId, implementation) {
provided.set(capabilityId, implementation);
},
resolve(_capabilityId: CapabilityId): RegisteredCapability | undefined {
return undefined;
},
},
moduleId: "example",
});
expect(moduleRuntime).toMatchObject({ id: "example", version: "0.1.0" });
expect(provided.get("example.records")).toBe(recordsCapability);
});
});