feat: add module contracts and discovery
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { defineModule } from "../src/index.js";
|
||||
|
||||
describe("defineModule", () => {
|
||||
it("returns a validated and normalized public manifest", () => {
|
||||
const module = defineModule({
|
||||
manifestVersion: 1,
|
||||
id: "example",
|
||||
name: "Example",
|
||||
version: "0.1.0",
|
||||
compatibility: {
|
||||
platform: "^0.1.0",
|
||||
moduleSdk: "^0.1.0",
|
||||
},
|
||||
entrypoints: {
|
||||
server: "./src/server/index.ts",
|
||||
},
|
||||
});
|
||||
|
||||
expect(module.capabilities).toEqual([]);
|
||||
expect(module.permissions).toEqual([]);
|
||||
expect(module.storage.buckets).toEqual([]);
|
||||
});
|
||||
|
||||
it("rejects invalid module definitions before runtime registration", () => {
|
||||
expect(() =>
|
||||
defineModule({
|
||||
manifestVersion: 1,
|
||||
id: "Not Valid",
|
||||
name: "Invalid",
|
||||
version: "0.1.0",
|
||||
compatibility: {
|
||||
platform: "^0.1.0",
|
||||
moduleSdk: "^0.1.0",
|
||||
},
|
||||
entrypoints: {
|
||||
server: "./src/server/index.ts",
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user