@bernierllc/nevar
v0.1.0
Published
Umbrella suite for the Nevar rules engine — re-exports all public APIs from a single entry point
Readme
@bernierllc/nevar
Umbrella suite for the Nevar rules engine. Re-exports all public APIs from a single entry point.
Installation
npm install @bernierllc/nevarUsage
import { createNevar, Nevar, Types, Storage } from '@bernierllc/nevar';
// Create engine with in-memory storage
const engine = createNevar({
storage: new Storage.InMemoryStorageAdapter(),
});
// Register a trigger
engine.registerTrigger('order.placed', {
payloadSchema: { type: 'object' },
description: 'Fired when an order is placed',
});
// Register an operator (use built-in or custom)
engine.registerOperator('greaterThan', {
evaluate: (fieldValue, conditionValue) => fieldValue > conditionValue,
});
// Register an action
engine.registerAction('send_email', {
handler: async (params) => ({ success: true }),
label: 'Send Email',
category: 'notifications',
});
// Create a rule and emit
await engine.createRule({
name: 'High value order',
groupId: 'default',
triggerType: 'order.placed',
conditions: { all: [{ field: 'amount', operator: 'greaterThan', value: 100 }] },
actions: [{ type: 'send_email', params: { to: '[email protected]' } }],
enabled: true,
priority: 1,
});
const result = await engine.emit('order.placed', { amount: 200 });Namespace Exports
All sub-packages are available as namespace imports to avoid naming conflicts:
import {
Types,
OperatorRegistry,
TriggerRegistry,
ActionRegistry,
ConditionTree,
Evaluator,
ContextBuilder,
ActionResolver,
ActionExecutor,
LoopDetector,
CircuitBreaker,
LoopController,
MixinBridge,
Storage,
AdapterPrisma,
LifecycleEvents,
AuditLogger,
Engine,
RuleSeeder,
} from '@bernierllc/nevar';License
SEE LICENSE IN LICENSE
