feat: add module schema discovery and validation
This commit is contained in:
@@ -4,7 +4,9 @@ import {
|
||||
parseModuleManifest,
|
||||
type RegisteredCapability,
|
||||
} from "@ekklesia/module-sdk";
|
||||
import { getTableConfig } from "drizzle-orm/pg-core";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import moduleSchema, { records } from "../src/schema/index.js";
|
||||
import moduleRuntime, { recordsCapability } from "../src/server/index.js";
|
||||
|
||||
describe("module template", () => {
|
||||
@@ -16,6 +18,7 @@ describe("module template", () => {
|
||||
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"]);
|
||||
expect(manifest.entrypoints.schema).toBe("./dist/schema/index.js");
|
||||
});
|
||||
|
||||
it("exports the typed runtime definition used by the compiled server entrypoint", async () => {
|
||||
@@ -35,4 +38,10 @@ describe("module template", () => {
|
||||
expect(moduleRuntime).toMatchObject({ id: "example", version: "0.1.0" });
|
||||
expect(provided.get("example.records")).toBe(recordsCapability);
|
||||
});
|
||||
|
||||
it("exports a namespaced module-owned Drizzle schema", () => {
|
||||
expect(moduleSchema.moduleId).toBe("example");
|
||||
expect(moduleSchema.tables.records).toBe(records);
|
||||
expect(getTableConfig(records)).toMatchObject({ name: "example_records", schema: undefined });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user