feat: add module contracts and discovery
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@ekklesia/module-sdk",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --project tsconfig.build.json",
|
||||
"lint": "biome lint .",
|
||||
"prepack": "pnpm --workspace-root exec turbo run build --filter=@ekklesia/module-sdk",
|
||||
"test": "vitest run",
|
||||
"typecheck": "tsc --noEmit --project tsconfig.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ekklesia/contracts": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "2.5.3",
|
||||
"@types/node": "24.13.3",
|
||||
"typescript": "7.0.2",
|
||||
"vitest": "4.1.10"
|
||||
},
|
||||
"ekklesia": {
|
||||
"layer": "module-sdk"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import {
|
||||
type ModuleManifest,
|
||||
type ModuleManifestInput,
|
||||
parseModuleManifest,
|
||||
} from "@ekklesia/contracts";
|
||||
|
||||
export function defineModule(manifest: ModuleManifestInput): ModuleManifest {
|
||||
return parseModuleManifest(manifest);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "@ekklesia/contracts";
|
||||
export * from "./define-module.js";
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"noEmit": false,
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"sourceMap": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["src/**/*.test.ts", "tests"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../typescript-config/node.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"types": ["node", "vitest/globals"]
|
||||
},
|
||||
"include": ["src/**/*.ts", "tests/**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user