Premium

Optimistic / offline mutation queues

Reflect accepted mutations immediately in a runtime snapshot while their delivery is pending. Offline queues, retries, and rollback paths let the application show progress without treating an optimistic change as a confirmed backend commit.

Optimistic / offline mutation queues — Screenshot of actual package API results with sample data. The read-only result table is application-owned; this feature does not provide this screen as built-in UI. Uses an in-memory test backend; no external service is connected. Preview build: @wts-calendar/core@1.1.0 (unpublished).
Screenshot of actual package API results with sample data. The read-only result table is application-owned; this feature does not provide this screen as built-in UI. Uses an in-memory test backend; no external service is connected. Preview build: @wts-calendar/core@1.1.0 (unpublished).

What you configure

online / setOnline
Communicate application connectivity to the workflow.
autoFlush / flush
Use automatic flushing or explicitly control delivery.
persistQueue / maxAttempts
Provide queue persistence and a retry ceiling appropriate to your transport.

Integration code example

  1. Connect a licensed workflow engine to your events and backend adapter.
  2. Render optimistic snapshots and expose pending, approval, or conflict state to users.
  3. Restore connectivity, flush intended work, and reconcile the canonical result returned by the backend.

Copy this TypeScript into your application, not the browser console. Replace YOUR_WTS_LICENSE_KEY with an entitlement issued for your deployment origin. A WTS license is not a Google, Microsoft or CalDAV credential. These examples are documentation only and never execute on this page.

Install command
npm install @wts-calendar/core
TypeScript integration
import { verifyCalendarLicense } from '@wts-calendar/core';
import { EnterpriseCalendarWorkflow } from '@wts-calendar/core/enterprise-workflow';
import type { WtsCalendar } from '@wts-calendar/core';
const license = await verifyCalendarLicense('YOUR_WTS_LICENSE_KEY');
const workflow = new EnterpriseCalendarWorkflow({
  license,
  actor: { id: 'editor-1', roles: ['editor'] },
  online: false,
  autoFlush: false,
  events: [
    {
      id: 'release',
      title: 'Release window',
      start: '2026-09-07T09:00:00Z',
      end: '2026-09-07T10:00:00Z',
    },
  ],
  defaultPermission: 'deny',
  permissionPolicies: [
    {
      id: 'editor-update',
      effect: 'allow',
      actions: ['update', 'flush'],
      roles: ['editor'],
    },
  ],
});

await workflow.submit({
  type: 'update',
  eventId: 'release',
  changes: { title: 'Optimistic title' },
});
console.log(workflow.getMutationQueue(), workflow.getEvent('release'));

// Render optimistic records through an existing web-calendar controller.
export function bindCalendar(calendar: Pick<WtsCalendar, 'setEvents'>) {
  const render = () =>
    calendar.setEvents(workflow.getEvents().map((record) => ({ ...record.event })));
  render();
  const unsubscribe = workflow.subscribe(render);
  return unsubscribe; // Call during unmount; do not leak listeners.
}
export async function reconnect(signal: AbortSignal) {
  workflow.setOnline(true);
  return workflow.flush({ signal });
}

Application responsibilities

This sample is runtime-only and initially offline. No database or WTS backend is required. Without your own backend adapter, flush commits only in memory and reload loses the state.

Actor IDs and roles are sample data, not authentication. A shared backend must authenticate users and independently enforce permissions, approval stages and event versions.

Set online state from your application connection lifecycle. For delivery or durable queues, supply your own backend with sendMutation and persistQueue; this example does not implement persistence.

Behavior and lifecycle

  • Only one unsettled mutation per event is allowed, preventing ambiguous rollback order.
  • Conflict, rejection, cancellation, or exhausted retry paths restore the captured pre-mutation record.

Limits and responsibilities

  • An in-memory queue does not survive reloads unless your application supplies suitable persistence and recovery handling.
  • Offline operation does not bypass approvals, permissions, or server-side concurrency checks.
Premium

Enable this capability

Optional module
@wts-calendar/core/enterprise-workflow
Signed entitlement
enterprise-workflow

Request the required features and deployment origins by email. Pricing and terms are confirmed privately. A WTS license is separate from provider credentials; do not send passwords or production access tokens.

Email for a license key →

This public guide does not execute Premium modules or collect license tokens.