Platform · Extensions
Custom code where configuration ends.
Eighty-five percent of scheduling logic fits in JSON. The other fifteen percent — proprietary algorithms, third-party API calls, domain validators that need real code — lives in extensions. Sandboxed TypeScript, signed and version-pinned, with a clean interface to the engine.
Three extension types
Calculators, allocators, validators.
Each type has a typed interface, a clear contract with the engine, and a place where it gets called. The engine doesn’t care whether a hook is built-in or an extension — they slot into the same chain.
ICalculationFunctionCalculation functions
Compute a value from inputs — travel time, dynamic credit cost, capacity-adjusted score. Called when the engine needs a number that isn’t in the template.
Reference example
TravelTimeCalculatorIBusinessRuleValidatorBusiness rule validators
Run as constraint gates in the validation chain. Pass or fail with structured errors. Used for domain rules JSON expressions can’t capture.
Reference example
CarePlanValidatorIResourceAllocatorResource allocators
Rank candidate slots and resources. The engine calls them after generating viable options. Used for optimization logic — merged visits, route optimization, cost minimization.
Reference example
MergedVisitOptimizerWhat real extensions look like
Real code. Real interfaces.
Three of the reference extensions that ship with FlexiScheduler domain templates. Each is a single TypeScript file implementing a typed interface.
TravelTimeCalculator
Computes travel time between two points, adding mobility-specific buffers. Called by the constraint chain when validating the daily-hour-limit constraint for Home Care.
Called by
Daily hour limit constraint, route optimization, transportation booking
import { ICalculationFunction } from '@flexischeduler/extension-sdk';
export class TravelTimeCalculator implements ICalculationFunction {
name = 'TravelTimeCalculator';
version = '1.0.0';
async calculate(ctx, params: {
origin: GeoLocation;
destination: GeoLocation;
mobility_type: 'ambulatory' | 'wheelchair' | 'stretcher';
}): Promise<number> {
const route = await ctx.googleMaps.directions({
origin: params.origin,
destination: params.destination,
});
// Add mobility-specific buffer
const buffer = { ambulatory: 5, wheelchair: 15, stretcher: 25 };
return route.duration_minutes + buffer[params.mobility_type];
}
}CarePlanValidator
Pulls the participant’s care plan from NetSmart and validates the requested activity is approved. Returns structured errors with remediation suggestions.
Called by
Constraint validation chain, treatment order intake, care coordination workflows
import { IBusinessRuleValidator } from '@flexischeduler/extension-sdk';
export class CarePlanValidator implements IBusinessRuleValidator {
name = 'CarePlanValidator';
version = '1.0.0';
async validate(ctx, { event, participant }) {
const carePlan = await ctx.netSmart.getCarePlan(participant.care_plan_id);
if (!carePlan.approved_activities.includes(event.activity_type)) {
return ctx.fail({
code: 'CARE_PLAN_MISMATCH',
message: `activity_type "${event.activity_type}" not in approved_activities`,
suggestions: carePlan.approved_activities,
});
}
return ctx.pass();
}
}MergedVisitOptimizer
Looks at a participant’s existing same-day events and boosts the score of slots that would consolidate visits. Drives the merged-visit metric on the Home Care vertical.
Called by
Alternative ranking, suggestion API, optimization scheduled jobs
import { IResourceAllocator } from '@flexischeduler/extension-sdk';
export class MergedVisitOptimizer implements IResourceAllocator {
name = 'MergedVisitOptimizer';
version = '1.0.0';
async allocate(ctx, request, candidates) {
// Look for participant's existing same-day events
const sameDay = await ctx.events.findByEntity({
entity_id: request.primary_entity_id,
date: request.start_time,
});
return candidates
.map((slot) => ({
...slot,
score: slot.score + (this.canMerge(slot, sameDay) ? 30 : 0),
}))
.sort((a, b) => b.score - a.score);
}
}Runtime guarantees
Sandboxed, signed, observable.
Extensions are user code running inside the engine. The runtime is built to keep them isolated, observable, and recoverable — so a bad extension cannot take down scheduling for the whole organization.
Sandboxed execution
VM2-isolated runtime. No filesystem, no child processes, no network unless declared. Module imports limited to a vetted allowlist.
Versioned and pinned
Templates pin extension versions explicitly. Upgrading is a deliberate template change, not a silent runtime swap. Multiple versions can run side-by-side.
Code signing
Extension code is signed at upload and verified at load. Tampered code refuses to execute. Audit log captures every load and every execution.
Timeout-bounded
Each extension declares a timeout. The runtime kills slow executions and falls back to defined defaults. Slow extensions never wedge the request path.
Tracing built in
Every extension call gets a span in the request trace. Latency, success rate, error rate exported as standard metrics.
Dependency declaration
Extensions declare external services they depend on (Google Maps, NetSmart, etc.). The runtime injects clients with credentials from customer config.
Extensions are a last resort, not a default
Ready to write your first extension
We’ll walk through the SDK live.
Thirty-minute walkthrough. We’ll write a sample validator, sign it, deploy it, and watch it run in the constraint chain. Bring an algorithm or rule that doesn’t fit JSON.