Extension SDK
Overview
Custom TypeScript code where JSON templates end. When to reach for an extension, when not to, and how to set up your dev environment.
Key points
- Extensions are sandboxed TypeScript modules that plug into the engine
- Three types — calculation functions, business rule validators, resource allocators
- Most customizations should fit in JSON templates; extensions are for the 1-5% that genuinely cannot
- Extensions run timeout-bounded, signed, version-pinned, with full tracing in production
When to use extensions
Templates handle the vast majority of customization. The four-tier inheritance model covers entity attributes, constraints, event types, notifications, and integrations through JSON. Reach for an extension only when configuration genuinely cannot express the logic.
Yes, write an extension
- You need to call an external service during scheduling (a mapping API, a clinical decision support service, a rate calculator)
- You have a proprietary algorithm — route optimization, dynamic pricing, ML-driven scoring — that’s differentiated intellectual property
- Your validation logic depends on continuously-changing external data that can’t be replicated (real-time inventory, live traffic conditions, fluctuating regulatory limits)
No, configure it in the template
- Static rule changes — operating hours, holiday lists, capacity limits, attribute requirements
- Conditional logic that can be expressed as attribute-comparisons (skill matching, tier-based limits, time-window restrictions)
- Notification routing, recipient selection, channel preferences — these all live in template notification config
Extensions are a last resort
The three extension types
Each extension type implements a specific interface and gets called by the engine at a defined point in the request path.
- Calculation 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.
- Business 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.
- Resource allocators — rank candidate slots and resources. The engine calls them after generating viable options. Used for optimization logic.
Each type has its own page with the full interface, a real implementation example, and integration patterns.
Project setup
Extensions live in their own repository — usually one per organization, but multi-template setups can split them. Install the SDK as a dev dependency:
npm install @flexischeduler/extension-sdk --save-dev
# Or with your preferred package manager
yarn add -D @flexischeduler/extension-sdk
pnpm add -D @flexischeduler/extension-sdkThe recommended project layout:
your-flexischeduler-extensions/
├── package.json
├── flexi.config.json # Extension manifest, references templates
├── src/
│ ├── calculators/
│ │ └── TravelTimeCalculator.ts
│ ├── validators/
│ │ └── CarePlanValidator.ts
│ ├── allocators/
│ │ └── MergedVisitOptimizer.ts
│ └── shared/ # Helpers reused across extensions
└── tests/
├── TravelTimeCalculator.test.ts
└── ...The SDK ships with TypeScript types for every interface, a local test runner that simulates the sandboxed runtime, and a CLI for validating your manifest before deploying. Most teams add the manifest validator to their CI pipeline.
Manifest
Extensions are declared in a manifest file at the root of your repository. The manifest tells FlexiScheduler which extensions exist, what type they are, and which template they bind to:
{
"$schema": "https://flexischeduler.com/schema/extension-manifest.json",
"organizationId": "org_a91e",
"templateId": "home_care_v1",
"extensions": [
{
"id": "travel_time_calculator",
"type": "calculation_function",
"entry": "src/calculators/TravelTimeCalculator.ts",
"version": "1.2.0",
"timeoutMs": 10000
},
{
"id": "care_plan_validator",
"type": "business_rule_validator",
"entry": "src/validators/CarePlanValidator.ts",
"version": "1.0.0"
}
]
}Each extension entry carries:
id— referenced from your template to invoke the extensiontype— one ofcalculation_function,business_rule_validator,resource_allocatorentry— relative path to the TypeScript fileversion— semver; templates pin extension versions explicitlytimeoutMs— optional; defaults are per-type (calculators 5s, validators 10s, allocators 30s)
What to read next
Three reference pages, one per extension type. Each has the full interface, a working example, and how it integrates with the engine’s request path:
- Calculation functions — start here if you need to compute travel time, dynamic cost, or scoring values
- Validators — start here if you need to enforce a domain rule that JSON can’t express
- Allocators — start here if you’re building optimization logic
Then the operational pages — Sandboxing for what’s allowed in the runtime, Testing for the local test harness and CI integration.