export type Primitive = string | number | boolean | null ; export const toPrimitiveOrUndefined = ( v ) : Primitive | undefined => { if ( typeof v === 'number' || typeof v === 'boolean' || typeof v === 'string' || v === null ) return v ; if ( typeof v === 'object' && v instanceof Date ) return v . toISOString ( ) ; if ( typeof v === 'undefined' ) return undefined ; return String ( v ) ; } ; export const deleteUndefinedKeys = < T extends Record < string , unknown > > ( obj ) : T => { Object . keys ( obj ) . forEach ( ( key ) => { if ( obj [ key ] === undefined ) { delete obj [ key ] ; } } ) ; return obj ; } ;