feat(surface): trigger namespaces for every relayfile adapter with webhooks - #456
Merged
Merged
Conversation
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.
Stacked on #446 (
feat/github-trigger-vocabulary); rebase ontomainonce it merges. Draft until the merge condition below is met.Why
flow().on(...)could subscribe to Slack and GitHub only.scripts/generate-triggers.mjsread the mapping YAML bundled in@relayfile/adapter-core, and that was the two core fallbacks — while relayfile ingests events from 47 providers (linear 33, gitlab 47, ramp 47, notion 13, cloudflare 8, …).What
The generator applies three sources per provider, in order:
mappings/*.mapping.yaml);mappings/adapters/*.mapping.yamlin the package once relayfile-adapters#280 ships,packages/<adapter>/in a checkout — superseding the fallback as a whole;@relayfile/adapter-core/triggers(KNOWN_TRIGGER_CATALOG, fed by every adapter'ssupportedEvents()) for providers with nowebhooks:block.Mapping-backed providers keep payload-aware signatures (
github.pull_request(action?)); catalog-backed ones get(filter?). 47 namespaces, 570 events (catalog events unioned into every provider; a mapping only adds payload shape) — full table in the generatedpackages/surface/src/triggers/PROVIDERS.md(covered by--check).github/slackare strict supersets of #446's output (6 fallback GitHub events and their signatures unchanged), soflows deploy --on github:events=…is unaffected. Hyphenated ids become identifiers (azure_blob.file_created()lowers to{ provider: 'azure-blob', type: 'file.created' }); a reserved-namespace guard refuses a provider named like a surface export (webhook,flow,schedule, …).flows check's provider-event refusal (provider-trigger-contract.ts) readsproviderEventTypes, so it now covers all 47 with no change of its own.Merge condition
@relayfile/adapter-core≥ 0.5.26, then bump the pin inpackages/sdk/package.json, runnode scripts/generate-triggers.mjs --check, un-draft.--check(andtests/generate-triggers.test.ts"reproduces all checked-in modules") reports drift ongithub.ts,gitlab.ts,index.ts,PROVIDERS.mdonly — 45 of 47 providers already generate identically from the catalog 0.5.25 ships.Tests
triggers-all-providers.test.ts(≥40 providers present; every registry event has a frozen namespace method lowering to{provider,type}; hyphenated ids; catalog-only signature),triggers-github-events.test.tsrelaxed to a superset.(filter?), mapping-backed never overridden,PROVIDERS.mdgenerated and drift-checked, reserved namespaces refused);provider-trigger-contract.test.tsaccepts one subscription from each of github/slack/linear/notion/gitlab, refusesno.such.eventon five providers, andflows checkpasses a five-provider flow.What Cloud still gates (not implemented here)
Local ingress delivers any of these providers today (
flows serve-webhook→POST /providers/<name>→providerInboxEvent). Hosted deployments do not:cloud/packages/web/lib/flows/flow-trigger-sources.ts(FLOW_TRIGGER_PROVIDERS = ["github","linear","jira","shortcut","slack"],flowIssueFromEvent→ per-provider*IssueFromEvent) andlaunch-flow-deployment.ts(skipped: "not_a_ticket",inputs: { approver, issue, event }) admit only ticket-shaped events from those five, plus PR events after cloud#3772;prepare-flow-deploy.tsbuilds watch rules from the same list (buildFlowWatchRules,flowSourceTriggers).Proposed generalisation: at deploy time, derive the deployment's subscriptions from the flow's declared sources — each
.on(<provider>.<event>(filter))is{ provider, eventType, filter }(already whatproviderDeclaration()extracts in the SDK) — persist them on the deployment record (flow-deployment-store.ts), build one watch rule per(provider, eventType)on that provider's relayfile projection (the rule paths per provider come from each adapter'sinbound.ts/ path-mapper, not a hand-kept table), and inlaunch-flow-deployment.tsadmit any delivered event whose(provider, eventType)the deployment declared, passing the raw record asinputs.eventand dispatching the matching handler body (the #301 handler-dispatch work) — withissue/pullRequestprojections kept as conveniences for the five ticket providers. Until #301 lands, the default body runs withinputs.eventonly.🤖 Generated with Claude Code
Summary by cubic
Adds trigger namespaces for every relayfile adapter provider, so
flow().on(...)can subscribe to all 47 providers (570 events) instead of only GitHub and Slack. The generator now merges core fallback mappings, adapter-local mappings, and the trigger catalog, and unions catalog events into every provider so awebhooks:block can no longer hide events ingress actually delivers. Mapping-backed providers keep payload-aware signatures likegithub.pull_request(action?), while catalog-only events take(filter?); GitHub and Slack are strict supersets, so existing subscriptions keep their signatures.Details
@relayfile/adapter-coreto 0.5.26, which bundles adapter-local mappings, and regenerates all trigger modules from the installed tarball;generate-triggers.mjs --checknow passes.azure_blob) but keep their upstream spelling when lowered.PROVIDERS.mdis covered by the generator's drift check, andflows checknow admits events from all 47 providers.webhook,flow, andschedule.github.check_run(action?)andgithub.issue_comment(action?), andflows deploy --on github:events=pull_requestnow selects PR events for hosted GitHub listeners.pull_request_editednow take a plain(filter?); only aggregate events (pull_request,check_run,issue_comment) still accept an action, and both spellings stay because two ingresses deliver them.reaction.addedandreaction_added), the mapping-declared event owns the method and the other stays inproviderEventTypes, subscribable viawebhook(...).Not included
Written for commit 179fb09. Summary will update on new commits.
Note
Medium Risk
Large generated public API surface and expanded
providerEventTypesaffectflows checkand all provider subscriptions; backward compatibility relies on GitHub/Slack remaining supersets of prior exports.Overview
Expands flow trigger authoring from GitHub and Slack only to 47 providers and 570 events by regenerating
@relayflows/surfacetrigger modules from an upgraded generator and@relayfile/adapter-core0.5.26.generate-triggers.mjsnow merges three inputs per provider: core fallback mappings, adapter-local mappings (new in adapter-core), andKNOWN_TRIGGER_CATALOG(unioned so catalog events are always present; mapping YAML only shapes signatures for events it declares). It emits per-provider TypeScript namespaces, an expandedproviderEventTypesregistry, and a drift-checkedPROVIDERS.md. Mapping-backed events keep payload-aware APIs (e.g.github.pull_request(action?)); catalog-only events use(filter?). Action-qualified names likepull_request.editedstay filter-only even when the mapping extractsaction. Colliding identifiers favor mapping-declared events; registry-only duplicates remain valid viawebhook(provider, { provider, type }). Reserved surface names (webhook,flow,schedule, …) are rejected as provider namespaces.GitHub and Slack are strict supersets of the prior vocabulary (existing six GitHub mapping events and signatures preserved). Tests cover catalog union, drift on
PROVIDERS.md, multi-providerflows check, and namespace coverage across providers.Reviewed by Cursor Bugbot for commit 179fb09. Bugbot is set up for automated code reviews on this repo. Configure here.