Skip to main content

Gate Functions Overview

Gate functions are the core of CalendarPipe's programmable sync engine. They are JavaScript functions that run inside a secure QuickJS WASM sandbox and decide what happens to each event as it flows from a source calendar to a target calendar.

Every sync rule has a gate function. When CalendarPipe syncs events, each event passes through the gate function, which can:

  • Pass the event through unchanged
  • Block the event from syncing
  • Transform the event (change its title, description, visibility, or free/busy status)

Hello World

The simplest gate function passes all events through without modification:

function gate(event: GateEvent): GateResult {
return { pass: true };
}

When pass is true, the event syncs to the target calendar. When pass is false, the event is blocked.

GateEvent

Each event that reaches your gate function is a GateEvent object containing the event's properties -- title, description, start/end times, attendees, and more. CalendarPipe also enriches events with computed convenience properties like durationMinutes, isWeekday, and dayOfWeek.

For a full list of all available properties, see the Property Reference.

GateResult

Your gate function returns a GateResult that tells CalendarPipe what to do with the event:

interface GateResult {
pass: boolean; // true = sync, false = block
reason?: string; // Human-readable reason (max 200 chars, only for pass: false)
transform?: {
title?: string; // Override title (max 500 chars)
description?: string; // Override description (max 5000 chars)
visibility?: 'default' | 'public' | 'private';
showAs?: 'free' | 'busy';
};
}

Four Ways to Create Gate Functions

CalendarPipe offers four authoring modes so you can create gate functions regardless of your technical background:

ModeBest ForDescription
TemplatesQuick setupChoose from 5 built-in presets (Pass All, Block Personal, Redact, Add Prefix, Set Free)
Visual BuilderNon-developersBuild rules with a point-and-click condition editor -- no code required
Code EditorDevelopersWrite TypeScript gate functions with full type definitions and a test-before-save workflow
AI GeneratorEveryoneDescribe what you want in plain English and let AI generate the gate function for you
tip

You can switch between authoring modes at any time. For example, start with a template, then customize it in the Code Editor.