Skip to content

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

Every extension you write is code your team has to maintain, version, test, and deploy. JSON template changes flow through the Config Studio without engineering involvement; extensions require code review and release. Stay in JSON until you can’t.

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-sdk

The 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:

flexi.config.jsonjson
{
  "$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 extension
  • type — one of calculation_function, business_rule_validator, resource_allocator
  • entry — relative path to the TypeScript file
  • version — semver; templates pin extension versions explicitly
  • timeoutMs — 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.