@bernierllc/nevar-adapter-prisma
v0.1.0
Published
Prisma storage adapter for the Nevar rules engine, with schema partial for easy integration
Readme
@bernierllc/nevar-adapter-prisma
Prisma storage adapter for the Nevar rules engine. Provides a NevarStorageAdapter implementation backed by Prisma ORM, plus a schema partial for easy integration into your Prisma schema.
Installation
npm install @bernierllc/nevar-adapter-prisma @bernierllc/nevar-typesSchema Setup
Copy or merge the schema partial from prisma/nevar.prisma into your project's schema.prisma file.
Usage
import { PrismaClient } from '@prisma/client';
import { PrismaAdapter } from '@bernierllc/nevar-adapter-prisma';
const prisma = new PrismaClient();
const adapter = new PrismaAdapter(prisma);
// Use with the Nevar engine
const group = await adapter.createGroup({
name: 'My Rules',
slug: 'my-rules',
isActive: true,
isDefault: false,
rules: [],
metadata: {},
createdAt: new Date(),
updatedAt: new Date(),
});API
PrismaAdapter
Full NevarStorageAdapter implementation backed by Prisma ORM. Handles group/rule CRUD, execution log writes, and paginated log queries. Maps between Prisma row shapes and Nevar domain types.
constructor(prisma: NevarPrismaClient)- Create an adapter with a Prisma client instancecreateGroup(group)/getGroup(id)/updateGroup(id, patch)/deleteGroup(id)/listGroups(filters?)- Group operationscreateRule(rule)/getRule(id)/updateRule(id, patch)/deleteRule(id)/listRules(filters?)- Rule operationswriteLog(entry)/listLogs(filters?)- Execution log operations
Prisma Client Types
NevarPrismaClient- Expected Prisma client shape withnevarRuleGroup,nevarRule,nevarAction,nevarExecutionLogdelegatesPrismaRuleGroupRow/PrismaRuleRow/PrismaActionRow/PrismaExecutionLogRow- Row types matching the Prisma schema
Integration Documentation
Logger Integration
This package integrates with @bernierllc/logger for structured logging. The Prisma adapter logs database operations, query failures, and mapping errors. Use logger for observability into storage-layer performance and error conditions.
NeverHub Integration
This package supports optional integration with @bernierllc/neverhub-adapter. When NeverHub is available, the Prisma adapter can register for discovery and monitoring, exposing connection health and query metrics. Graceful degradation is supported when NeverHub is not present.
License
Copyright (c) 2025 Bernier LLC. All rights reserved.
