Hermes 284313f908
Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

2.6 KiB

Scheduler Demo Extension

This sample extension demonstrates how to use the cap:scheduler.manage capability to programmatically create, update, and delete scheduled tasks for your extension.

Features

  • Self-Configuration: The extension sets up its own scheduled tasks when /api/setup is called
  • Schedule Management: List, create, and delete schedules through the UI
  • Schedulable Endpoints: Demonstrates endpoints marked as schedulable: true in the manifest

Capabilities Used

  • cap:scheduler.manage - Manage extension schedules
  • cap:log.emit - Write logs
  • cap:context.read - Read execution context

Endpoints

Method Path Schedulable Description
GET /api/status Yes Health check endpoint
POST /api/setup No Auto-configure schedules
GET /api/schedules No List all schedules
DELETE /api/schedules/:id No Delete a schedule
POST /api/heartbeat Yes Scheduled heartbeat

How It Works

Self-Configuration Pattern

When the extension's /api/setup endpoint is called, it:

  1. Discovers available schedulable endpoints via host.scheduler.getEndpoints()
  2. Checks for existing schedules to avoid duplicates
  3. Creates new schedules for the heartbeat and status endpoints
  4. Returns a summary of what was configured
// Example: Creating a schedule from within the extension
const result = await host.scheduler.create({
  endpoint: 'POST /api/heartbeat',
  cron: '*/5 * * * *', // Every 5 minutes
  timezone: 'UTC',
  enabled: true,
  name: 'Heartbeat Check',
  payload: JSON.stringify({ source: 'auto-setup' }),
});

Manifest Configuration

Endpoints must be marked as schedulable: true in the manifest to be eligible for scheduling:

{
  "api": {
    "endpoints": [
      { "method": "POST", "path": "/api/heartbeat", "handler": "dist/main", "schedulable": true }
    ]
  }
}

Building

npm install
npm run build
npm run pack  # Creates a deployable bundle

Testing

npm test

Usage in Production

  1. Install the extension with the cap:scheduler.manage capability enabled
  2. Navigate to the extension's UI via the app menu
  3. Click "Setup Schedules" to auto-configure the scheduled tasks
  4. Use "Refresh List" to view current schedules
  5. Delete schedules as needed through the UI

Notes

  • Extensions can only manage their own schedules
  • Schedules are scoped to the extension installation (tenant + extension)
  • The runNow functionality remains admin-only and is not exposed to extensions