feat(integrations): support chatRoomFilter and chat rule types#433
Draft
AndyTWF wants to merge 7 commits into
Draft
feat(integrations): support chatRoomFilter and chat rule types#433AndyTWF wants to merge 7 commits into
AndyTWF wants to merge 7 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Rules created from Ably Chat rooms populate chatRoomFilter (top-level on the rule, alongside source) instead of source.channelFilter. Surface it in both human-readable and JSON output so `integrations get`/`list` don't silently omit the filter for chat-room-sourced rules. DX-1546 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
AndyTWF
force-pushed
the
integrations-chat-room-filter
branch
from
July 17, 2026 15:51
e0c5230 to
f0ef330
Compare
Rules can be sourced from Ably Chat rooms (source-type chat.message), which requires setting chatRoomFilter rather than the channel-based source.channelFilter. `integrations create`/`update` had no way to set it, even though get/list already knew how to display it. Also corrects the example/test filter values to valid regex syntax (channelFilter/chatRoomFilter are regexps, not globs) — e.g. "room:.*" instead of "room:*". DX-1546
Extends the Control API e2e suite to create/get/list/delete a rule with source-type chat.message and --chat-room-filter, verifying chatRoomFilter round-trips through the real API end to end.
…ests channelFilter is a regexp, not a glob, so "chat:*" is invalid — the trailing * has nothing to repeat. Switch examples and test fixtures to "chat:.*" (and similarly for other filter values used in tests).
3 tasks
…sh rule types Ably Chat rules (hive/text-model-only, hive/dashboard, bodyguard/text-moderation, tisane/text-moderation, azure/text-moderation, aws/lambda/before-publish, and http/before-publish) use a structurally different schema from the classic Reactor rule types: invocationMode + beforePublishConfig instead of requestMode, and vendor-specific target shapes discovered by inspecting existing rules and probing the Control API directly. `integrations create` had no way to create any of these — only the classic channel-sourced rule types were supported. Along the way, found and fixed two bugs that blocked this entirely: chatRoomFilter and source.channelFilter were sent unconditionally (even as empty strings), which the API rejects outright for chat.message-sourced and before-publish rules. modelUrl was sent as an explicit null when unset, which the API also rejects — now omitted instead. DX-1546 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… test Extends the Control API e2e suite with a full create/get/delete lifecycle for every chat rule type (http/before-publish, hive/text-model-only, hive/dashboard, bodyguard/text-moderation, tisane/text-moderation, azure/text-moderation, aws/lambda/before-publish) against the real API. Also fixes the existing chat-room-sourced rule test, which used the "http" rule type — the real API rejects chatRoomFilter/chat.message on that schema, so this test would have failed had it ever actually run (it was silently skipped locally for lack of E2E_ABLY_ACCESS_TOKEN). Running the new tests against the real API surfaced two more things these tests now account for: the azure/text-moderation target.endpoint is validated via a live DNS lookup at creation time, so a placeholder domain 422s; and rule IDs can start with "-", which oclif misparses as an unknown flag unless a "--" separator precedes the positional arg. DX-1546 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…rule config update.ts and delete.ts printed "Request Mode: undefined" for chat rule types (they use invocationMode instead of requestMode) and never showed invocationMode at all — the same display bug already fixed in create.ts/ get.ts/list.ts was missed in these two commands. parseThresholds silently accepted "key=" and "key= " as a threshold of 0 instead of rejecting them, and discarded everything after a second "=". create.ts had no validation that a chat rule type is paired with --source-type chat.message (or vice versa), so a mismatched combination only surfaced as an opaque Control API 4xx instead of a clear CLI error. Replaces the CHAT_RULE_TYPES/AFTER_PUBLISH_CHAT_RULE_TYPES sets plus the per-rule-type switch statement with a single declarative config table (invocationMode, required target flags, target builder per rule type), removes the duplicate local IntegrationData/BeforePublishConfig types in favour of importing RuleData from control-api.ts, and extracts a shared buildModerationTarget helper for the three moderation-vendor rule types. DX-1546 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
AndyTWF
force-pushed
the
integrations-chat-room-filter
branch
from
July 23, 2026 18:44
b604c58 to
c2e85ad
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.
Summary
chatRoomFilter(top-level on the rule, alongsidesource) rather thansource.channelFilter.ably integrations get/listpreviously had no way to display this, so chat-room-sourced rules looked like they had no filter configured.integrations get/listnow show a "Chat Room Filter" line when set, and includechatRoomFilterin--jsonoutput.integrations create/updategained a--chat-room-filterflag andchat.messageas a--source-typeoption — but on their own these only covered the classic Reactor-style rule types (http,amqp, etc.), which turned out not to be the actual rule types Ably Chat rules use.invocationMode+beforePublishConfiginstead ofrequestMode, and a source object that rejectschannelFilterentirely.integrations createhad no way to create any of these rule types at all. This PR adds full support for all seven:http/before-publish,hive/text-model-only,hive/dashboard,bodyguard/text-moderation,tisane/text-moderation,azure/text-moderation, andaws/lambda/before-publish. Each gets its own typed target flags (--target-api-key,--target-endpoint,--target-function-name,--threshold key=value, etc.), andinvocationMode/beforePublishConfigare set automatically per rule type (onlyhive/dashboardrunsAFTER_PUBLISH; everything else isBEFORE_PUBLISHwith a configurable retry/failure policy).chatRoomFilterandsource.channelFilterwere being sent unconditionally (even as empty strings), which the Control API rejects outright forchat.message-sourced and before-publish rules — now both are only included when actually set. AmodelUrl: nulldefault was also rejected by the schema (it only accepts a string or omission) — now omitted when not provided.Rule/RuleDatainterfaces incontrol-api.tsupdated to match:invocationMode,beforePublishConfigadded,requestMode/source.channelFiltermade optional.integrations get/listalso surfaceinvocationModeand no longer print a blank "Request Mode" line for rule types that don't have one.channelFilter/chatRoomFilterexample and test values to valid regex syntax (e.g.chat:.*,room:.*) instead of glob-stylechat:*— both fields are regexps evaluated by the Control API, not globs.Test plan
pnpm prepare(build + manifest)pnpm exec eslint .— 0 errorspnpm test:unit— full suite passes (2553 tests)pnpm test:tty— passesintegrations create/get/list/updatecovering all seven chat rule types, required-flag validation per type,beforePublishConfigdefaults/overrides, and thehive/dashboardAFTER_PUBLISH/no-beforePublishConfigexceptiontest/e2e/integrations/integrations-e2e.test.ts) extended with a full create/get/delete lifecycle for every chat rule type, plus a fix to the existing chat-room-sourced test which used the wrong (http) rule type. Actually run against the real Control API (withE2E_ABLY_ACCESS_TOKEN/E2E_ABLY_API_KEY) this time — all 10 tests pass, including app create/teardownnode bin/run.js integrations create ...against a real app, then cleaned up the test rulesNotes from live verification
azure/text-moderation'starget.endpointis validated via a live DNS lookup at rule-creation time (422 onENOTFOUND), so the e2e test uses a real resolvable hostname rather than a placeholder.-(e.g.-MYkHg), which oclif's arg parser misreads as an unknown flag rather than a positional argument forintegrations get/delete. Worked around it in the new e2e tests with a--separator; flagging as a follow-up since it'd affect real users with an unlucky rule ID.DX-1546
Manual testing
Run against a local build of this branch (
pnpm preparethennode bin/run.js ...) — the globally installedablyCLI will be an older published version without this support.Chat Room Filter: room:.*andInvocation Mode: BEFORE_PUBLISH.channel.messagerules show neither:get: