feat(03-01): add Module SDK package and Prisma module registry schema

- Create @tessera/module-sdk with TesseraModule, ModuleRoute, ModuleManifest, ModuleCategory types
- Add Module and TenantModuleActivation Prisma models with tenant-scoped unique constraint
- Apply migration add-module-registry to PostgreSQL
- Framework-agnostic ComponentType for lazy-loaded module UIs
This commit is contained in:
2026-06-19 12:33:55 +02:00
parent 6e2f6e7c3e
commit 8c24c1e267
7 changed files with 183 additions and 0 deletions
@@ -0,0 +1,38 @@
-- CreateTable
CREATE TABLE "Module" (
"id" TEXT NOT NULL,
"slug" TEXT NOT NULL,
"name" TEXT NOT NULL,
"version" TEXT NOT NULL,
"category" TEXT NOT NULL,
"description" JSONB NOT NULL,
"icon" TEXT,
"isSystem" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "Module_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "TenantModuleActivation" (
"id" TEXT NOT NULL,
"tenantId" TEXT NOT NULL,
"moduleId" TEXT NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"activatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "TenantModuleActivation_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Module_slug_key" ON "Module"("slug");
-- CreateIndex
CREATE INDEX "TenantModuleActivation_tenantId_idx" ON "TenantModuleActivation"("tenantId");
-- CreateIndex
CREATE UNIQUE INDEX "TenantModuleActivation_tenantId_moduleId_key" ON "TenantModuleActivation"("tenantId", "moduleId");
-- AddForeignKey
ALTER TABLE "TenantModuleActivation" ADD CONSTRAINT "TenantModuleActivation_moduleId_fkey" FOREIGN KEY ("moduleId") REFERENCES "Module"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+26
View File
@@ -84,3 +84,29 @@ model LdapFieldMapping {
@@unique([ldapConfigId, ldapField])
}
model Module {
id String @id @default(uuid())
slug String @unique
name String
version String
category String
description Json
icon String?
isSystem Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
activations TenantModuleActivation[]
}
model TenantModuleActivation {
id String @id @default(uuid())
tenantId String
moduleId String
isActive Boolean @default(true)
activatedAt DateTime @default(now())
module Module @relation(fields: [moduleId], references: [id], onDelete: Cascade)
@@unique([tenantId, moduleId])
@@index([tenantId])
}