feat: add module schema discovery and validation
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import {
|
||||
type ModuleId,
|
||||
type ModuleSchemaDefinition,
|
||||
moduleTableName,
|
||||
moduleTablePrefix,
|
||||
parseModuleSchemaDefinition,
|
||||
} from "@ekklesia/contracts";
|
||||
import { pgTableCreator } from "drizzle-orm/pg-core";
|
||||
|
||||
export function createModuleTable(moduleId: ModuleId) {
|
||||
moduleTablePrefix(moduleId);
|
||||
return pgTableCreator((localName) => moduleTableName(moduleId, localName));
|
||||
}
|
||||
|
||||
export function defineModuleSchema<const Definition extends ModuleSchemaDefinition>(
|
||||
definition: Definition,
|
||||
): Readonly<Definition> {
|
||||
return parseModuleSchemaDefinition(definition) as Readonly<Definition>;
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "@ekklesia/contracts";
|
||||
export * from "./define-module-runtime.js";
|
||||
export * from "./define-module-schema.js";
|
||||
|
||||
Reference in New Issue
Block a user