import { FieldType } from '@terascope/types' ; import { FieldTransformConfig , ProcessMode , FunctionDefinitionType , DataTypeFieldAndChildren , FunctionDefinitionCategory } from '../interfaces' ; export const decodeBase64Config = { name : 'decodeBase64' , type : FunctionDefinitionType . FIELD_TRANSFORM , process_mode : ProcessMode . INDIVIDUAL_VALUES , category : FunctionDefinitionCategory . STRING , description : 'Returns the base64-decoded version of the input string' , examples : [ { args : { } , config : { version : 1 , fields : { testField : { type : FieldType . String } } } , field : 'testField' , input : 'c29tZSBzdHJpbmc=' , output : 'some string' , } ] , create ( ) { return ( input ) => Buffer . from ( input as string , 'base64' ) . toString ( 'utf8' ) ; } , accepts : [ FieldType . String ] , output_type ( inputConfig ) { const { field_config , child_config } = inputConfig ; return { field_config : { ... field_config , type : FieldType . String } , child_config } ; } , } ;