New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@bimetal/calendar-rules

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bimetal/calendar-rules

Calendar-domain rule pack: noOverlap, workingHoursOnly, min/maxDuration, domainRule, withRules store integration. Built on @bimetal/rule-engine.

latest
npmnpm
Version
0.42.0
Version published
Weekly downloads
43
-85.9%
Maintainers
1
Weekly downloads
 
Created
Source

@bimetal/calendar-rules

Calendar-domain rule pack: concrete rules, the domainRule factory, and withRules store integration. Built on @bimetal/rule-engine + @bimetal/calendar-data.

Installation

npm install @bimetal/calendar-rules

Built-in Rules

  • noOverlap — a CalendarRule value; rejects overlapping events
  • warnOnOverlap — a CalendarRule value; same check, but warning instead of error
  • workingHoursOnly — rejects events outside config.workingHours
  • minDuration(minutes), maxDuration(minutes) — duration guards
  • minGranularityDuration — derives min duration from config.granularity
  • domainRule({ id, description, domainKey, appliesTo?, evaluate }) — factory for rules that target events carrying a specific domain model

Store Integration

  • withRules(store, engine, config, caller?) — wraps a CalendarStore so every dispatch evaluates rules first; throws RuleViolationError on error-severity results
  • RuleAwareStore — CalendarStore plus lastWarnings for the most recent dispatch
  • RuleViolationError — thrown when a rule's evaluate returns { passed: false, severity: 'error' }

Calendar-flavored Types

  • CalendarRule — extends Rule<CalendarCommand, RuleContext> with optional domainKey
  • CalendarRuleResult — alias of the generic RuleResult
  • RuleContext — pinned to CalendarReadModel, CoreConfig, CalendarDateTime
  • RuleEngine — RuleEngine<CalendarCommand, RuleContext>

Convenience

createRuleEngine is re-exported from @bimetal/rule-engine so calendar consumers don't need a second import.

Example

import { createCalendarStore, createEvent } from '@bimetal/calendar-data';
import {
  createRuleEngine,
  noOverlap,
  workingHoursOnly,
  withRules,
} from '@bimetal/calendar-rules';
import { defaultConfig } from '@bimetal/calendar-core';
import { createDateTime, createTimeRange, Month } from '@bimetal/temporal';

const store = createCalendarStore();
const engine = createRuleEngine([noOverlap, workingHoursOnly]);
const guarded = withRules(store, engine, defaultConfig);

await guarded.dispatch(createEvent({
  id: 'e1',
  title: 'Standup',
  allDay: false,
  metadata: {},
  timeRange: createTimeRange(
    createDateTime(2026, Month.June, 17, 9, 0, 'UTC'),
    createDateTime(2026, Month.June, 17, 10, 0, 'UTC'),
  ),
})); // throws RuleViolationError on conflict

Note on Domain Filtering

CalendarRule.domainKey is an opaque hint. The generic engine does not filter rules by it (that would couple @bimetal/rule-engine to the calendar event shape). Instead, domainRule() checks the target event's domains[domainKey] inside its own evaluate and returns PASS when the domain is absent — same behavior as before, but cleanly decoupled.

Replaces

This package contains the calendar-specific portion of the (removed) @bimetal/rules. The generic engine lives in @bimetal/rule-engine.

License

Apache License 2.0

Keywords

calendar

FAQs

Package last updated on 30 Oct 2026

Related posts