11import { Args , Flags } from "@oclif/core" ;
22import { ControlBaseCommand } from "../../control-base-command.js" ;
3+
4+ // Rule types whose target has a `url` field updatable via --target-url.
5+ const HTTP_TARGET_URL_RULE_TYPES = new Set ( [ "http" , "http/before-publish" ] ) ;
6+
37// Interface for rule update data structure (most fields optional)
48interface PartialRuleData {
9+ chatRoomFilter ?: string ;
510 requestMode ?: string ;
611 ruleType ?: string ; // Usually shouldn't be updated, but kept for structure
712 source ?: {
@@ -24,7 +29,8 @@ export default class IntegrationsUpdateCommand extends ControlBaseCommand {
2429
2530 static examples = [
2631 "$ ably integrations update rule123 --status disabled" ,
27- '$ ably integrations update rule123 --channel-filter "chat:*"' ,
32+ '$ ably integrations update rule123 --channel-filter "chat:.*"' ,
33+ '$ ably integrations update rule123 --chat-room-filter "room:.*"' ,
2834 '$ ably integrations update rule123 --target-url "https://new-example.com/webhook"' ,
2935 "$ ably integrations update rule123 --status disabled --json" ,
3036 ] ;
@@ -39,6 +45,10 @@ export default class IntegrationsUpdateCommand extends ControlBaseCommand {
3945 description : "Channel filter pattern" ,
4046 required : false ,
4147 } ) ,
48+ "chat-room-filter" : Flags . string ( {
49+ description : "Chat room filter pattern" ,
50+ required : false ,
51+ } ) ,
4252 status : Flags . string ( {
4353 description : "Status of the rule" ,
4454 options : [ "enabled" , "disabled" ] ,
@@ -96,8 +106,15 @@ export default class IntegrationsUpdateCommand extends ControlBaseCommand {
96106 updatePayload . source . channelFilter = flags [ "channel-filter" ] ;
97107 }
98108
99- // Update target if it's an HTTP rule and target-url is provided
100- if ( existingRule . ruleType === "http" && flags [ "target-url" ] ) {
109+ if ( flags [ "chat-room-filter" ] ) {
110+ updatePayload . chatRoomFilter = flags [ "chat-room-filter" ] ;
111+ }
112+
113+ // Update target if it's an HTTP-based rule and target-url is provided
114+ if (
115+ HTTP_TARGET_URL_RULE_TYPES . has ( existingRule . ruleType ) &&
116+ flags [ "target-url" ]
117+ ) {
101118 // Ensure target exists before assigning to url
102119 if ( ! updatePayload . target ) updatePayload . target = { } ;
103120 updatePayload . target . url = flags [ "target-url" ] ;
@@ -124,12 +141,22 @@ export default class IntegrationsUpdateCommand extends ControlBaseCommand {
124141 this . log ( `ID: ${ updatedRule . id } ` ) ;
125142 this . log ( `App ID: ${ updatedRule . appId } ` ) ;
126143 this . log ( `Rule Type: ${ updatedRule . ruleType } ` ) ;
127- this . log ( `Request Mode: ${ updatedRule . requestMode } ` ) ;
144+ if ( updatedRule . requestMode ) {
145+ this . log ( `Request Mode: ${ updatedRule . requestMode } ` ) ;
146+ }
147+
148+ if ( updatedRule . invocationMode ) {
149+ this . log ( `Invocation Mode: ${ updatedRule . invocationMode } ` ) ;
150+ }
151+
128152 if ( updatedRule . source . channelFilter ) {
129153 this . log (
130154 `Source Channel Filter: ${ updatedRule . source . channelFilter } ` ,
131155 ) ;
132156 }
157+ if ( updatedRule . chatRoomFilter ) {
158+ this . log ( `Chat Room Filter: ${ updatedRule . chatRoomFilter } ` ) ;
159+ }
133160 this . log ( `Source Type: ${ updatedRule . source . type } ` ) ;
134161 if (
135162 typeof updatedRule . target === "object" &&
0 commit comments