npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@calenderjs/event-model

v0.0.2

Published

Event Data Model - Single Source of Truth (SSOT) for Event data structures

Readme

@calenderjs/event-model

Event Data Model - Single Source of Truth (SSOT) for Event data structures.

概述

此包提供 Event 数据模型的类型定义和 JSON Schema 验证,作为所有其他包的单一数据源(SSOT)。

职责

@calenderjs/event-model 包有两个核心职责:

  1. 定义数据模型和 JSON Schema

    • Event 接口定义(Event.ts
    • Event JSON Schema(validator.ts 中的 EVENT_BASE_SCHEMA
    • JSON Schema 类型定义(types.ts
  2. 使用 JSON Schema 验证数据

    • EventValidator 类(validator.tsvalidators/EventValidator.ts
    • 验证 Event 对象是否符合 Event Data Model
    • 验证 Event.data 字段是否符合指定的 JSON Schema

依赖关系

@calenderjs/event-model (SSOT)
    ↑                    ↑
    │                    │
@calenderjs/calendar  @calenderjs/event-dsl

导出

1. Event 接口和类型

import { Event, EventMetadata } from '@calenderjs/event-model';

const event: Event = {
  id: "event-1",
  type: "meeting",
  title: "团队会议",
  startTime: new Date("2025-01-15T10:00:00"),
  endTime: new Date("2025-01-15T11:00:00"),
  data: {
    attendees: ["[email protected]"],
    location: "会议室 A"
  }
};

2. Event JSON Schema

import { EVENT_BASE_SCHEMA } from '@calenderjs/event-model';

// EVENT_BASE_SCHEMA 定义了 Event 接口的 JSON Schema
// 用于验证 Event 对象的基本结构
console.log(EVENT_BASE_SCHEMA);

3. Event 验证器

import { EventValidator, EVENT_BASE_SCHEMA } from '@calenderjs/event-model';
import type { Event } from '@calenderjs/event-model';

const validator = new EventValidator();

// 验证 Event 对象是否符合 Event Data Model
const event: Event = {
  id: "event-1",
  type: "meeting",
  title: "团队会议",
  startTime: new Date("2025-01-15T10:00:00"),
  endTime: new Date("2025-01-15T11:00:00"),
  data: {}
};

const result = validator.validateBase(event);
if (!result.valid) {
  console.error('验证失败:', result.errors);
}

使用

在 calendar 包中使用

import type { Event } from '@calenderjs/event-model';

export class Calendar {
  private events: Event[] = [];
  
  addEvent(event: Event) {
    this.events.push(event);
  }
}

在 event-dsl 包中使用

import type { Event } from '@calenderjs/event-model';

export class EventRuntime {
  validate(event: Event): ValidationResult {
    // 验证逻辑
  }
}

相关 RFC

  • RFC-0001: Event Calendar DSL
  • RFC-0011: Event 数据模型与 Event DSL 集成