feat(automation): schedule flow trigger — auto-launch flows on cron/interval/once#1423
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…nterval/once
The time-based sibling of plugin-trigger-record-change. The automation engine
already parses a flow's start node into a `schedule` binding (flow.type ===
'schedule' or a start-node `config.schedule` descriptor) — shipped with the
record-change trigger PR — so this is purely the concrete trigger, with no
engine change.
New plugin @objectstack/plugin-trigger-schedule:
- ScheduleTrigger implements the engine's FlowTrigger extension point and
delegates timing to the platform IJobService (the 'job' service), staying
adapter-agnostic: the job service selects a cron-capable adapter (DbJobAdapter
/ CronJobAdapter) for cron and the interval adapter otherwise.
- normalizeSchedule accepts the canonical JobSchedule plus shorthands (bare cron
string, { cron }/{ expression }, { every }/{ intervalMs }, { at }).
- On fire the flow runs with event:'schedule' + params:{ jobId, flowName,
schedule }; the engine's start-condition gate still applies.
- Error-isolated (a flow failure never crashes the job runner); per-flow job
name so stop() cancels exactly one flow; job service resolved lazily per bind
so adapter upgrades (interval → durable Db) are picked up; graceful degrade
when automation/job service absent (kernel:ready + getService).
Depends on com.objectstack.service.job so its adapter upgrade runs first.
Tests: 17 (normalizeSchedule shapes/shorthands/rejects, schedule/cancel,
config.schedule fallback, fire→context, error isolation, idempotency, plugin
wiring + graceful degrade + lazy resolution). Builds clean (full DTS).
Adds the package to the changeset fixed group.
ab8e076 to
e5b9511
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The time-based sibling of #1421 (record-change trigger). Completes the schedule arm of the automation engine's
FlowTriggerextension point so a flow whose start node declares a schedule auto-launches on cron / interval / once — no manualengine.execute().No engine change — the engine already parses a flow's start node into a
schedulebinding (flow.type === 'schedule'or a start-nodeconfig.scheduledescriptor); that shipped with #1421. This PR is purely the concrete trigger plugin.New plugin:
@objectstack/plugin-trigger-scheduleScheduleTriggerimplements the engine'sFlowTriggerextension point and delegates timing to the platformIJobService(the'job'service). It stays adapter-agnostic — the job service selects a cron-capable adapter (durableDbJobAdapter/CronJobAdapter) for cron schedules and the interval adapter for the rest.normalizeScheduleaccepts the canonicalJobScheduleplus ergonomic shorthands: a bare cron string,{ cron }/{ expression },{ every }/{ intervalMs },{ at }.event: 'schedule'andparams: { jobId, flowName, schedule }; the engine's start-condition gate still applies.flow-schedule:<flowName>) sostop()cancels exactly one flow; idempotent re-bind.kernel:readyadapter upgrade (interval → durable Db) is always picked up.kernel:ready+getService, mirroringplugin-audit/ the record-change trigger).com.objectstack.service.jobso its adapter upgrade runs first.Usage
Tests
17 tests:
normalizeScheduleshapes / shorthands / rejects,schedule+cancel,config.schedulefallback, fire→context, error isolation, stop, idempotency, plugin wiring + graceful degrade + lazy resolution. Builds clean (full DTS typecheck).service-automation104 (no regression — no engine change).Follow-up
This completes the two trigger types the plan scoped (record-change + schedule). Strong-typing the start-trigger config in spec (engine reads it defensively today) remains an optional later cleanup.