1- import { resolveCommandResponseDataTransform } from './command-descriptor/registry.ts' ;
1+ import {
2+ listCommandResponseDataTransformFieldNames ,
3+ resolveCommandResponseDataTransform ,
4+ } from './command-descriptor/registry.ts' ;
25import type { ResponseDataFieldTransform } from './command-descriptor/types.ts' ;
36
47export type InteractionResponseDataTransformCommand = 'click' | 'press' | 'fill' ;
58
9+ const controlledResponseDataFieldNames = new Set ( listCommandResponseDataTransformFieldNames ( ) ) ;
10+
611export function transformInteractionResponseData ( params : {
712 command : InteractionResponseDataTransformCommand ;
813 input : Record < string , unknown > | undefined ;
@@ -12,6 +17,7 @@ export function transformInteractionResponseData(params: {
1217 fields : readCommandResponseDataTransformFields ( params . command ) ,
1318 input : params . input ?? { } ,
1419 data : params . data ,
20+ controlledFields : controlledResponseDataFieldNames ,
1521 } ) ;
1622}
1723
@@ -29,8 +35,11 @@ function applyResponseDataFieldTransforms(params: {
2935 fields : Record < string , ResponseDataFieldTransform > ;
3036 input : Record < string , unknown > ;
3137 data : Record < string , unknown > | undefined ;
38+ controlledFields : ReadonlySet < string > ;
3239} ) : Record < string , unknown > {
33- const transformed = { ...( params . data ?? { } ) } ;
40+ const transformed = Object . fromEntries (
41+ Object . entries ( params . data ?? { } ) . filter ( ( [ key ] ) => ! params . controlledFields . has ( key ) ) ,
42+ ) ;
3443 for ( const [ key , field ] of Object . entries ( params . fields ) ) {
3544 const value = params . input [ key ] === undefined ? field . defaultValue : params . input [ key ] ;
3645 if ( value === undefined || ( field . omitDefault === true && value === field . defaultValue ) ) {
0 commit comments