function extractFiles(value, key) {
    if (typeof value !== "object" || value === null)
        return [];
    return Object.entries(value).flatMap(([k, v]) => {
        const origin = key !== null && key !== void 0 ? key : k;
        if (Array.isArray(v))
            return v.flatMap((p) => extractFiles(p, origin));
        else if (v instanceof platform_node_js_1.InputFile) {
            const id = randomId();
            Object.assign(value, { [k]: `attach://${id}` });
            return { id, origin, file: v };
        }
        else
            return extractFiles(v, origin);
    });
}
/**
 * Replaces all instances of `InputFile` in a given payload by attach://
 * strings. This alters the passed object. After calling this method, the
 * payload object can be stringified.
 *
 * Returns a list of `InputFile` instances along with the random identifiers
 * that were used in the corresponding attach:// strings, as well as the origin
 * keys of the original payload object.
 *
 * @param value a payload object, or a part of it
 * @param key the origin key of the payload object, if a part of it is passed
 * @returns the cleaned payload object
 */
Replaces all instances of `InputFile` in a given payload by attach:
strings. This alters the passed object. After calling this method, the
payload object can be stringified.

Returns a list of `InputFile` instances along with the random identifiers
that were used in the corresponding attach:// strings, as well as the origin
keys of the original payload object.

@param value a payload object, or a part of it
@param key the origin key of the payload object, if a part of it is passed
@returns the cleaned payload object
Replaces all instances of ` InputFile ` in a given payload by attach : strings . This alters the passed object . After calling this method the payload object can be stringified . Returns a list of ` InputFile ` instances along with the random identifiers that were used in the corresponding attach : // strings as well as the origin keys of the original payload object . @param value a payload object or a part of it @param key the origin key of the payload object if a part of it is passed @returns the cleaned payload object
function extractFiles(value, key) {
    if (typeof value !== "object" || value === null)
        return [];
    return Object.entries(value).flatMap(([k, v]) => {
        const origin = key !== null && key !== void 0 ? key : k;
        if (Array.isArray(v))
            return v.flatMap((p) => extractFiles(p, origin));
        else if (v instanceof platform_node_js_1.InputFile) {
            const id = randomId();
            Object.assign(value, { [k]: `attach://${id}` });
            return { id, origin, file: v };
        }
        else
            return extractFiles(v, origin);
    });
}
function extractFiles ( value , key ) { if ( typeof value !== "object" || value === null ) return [ ] ; return Object . entries ( value ) . flatMap ( ( [ k , v ] ) => { const origin = key !== null && key !== void 0 ? key : k ; if ( Array . isArray ( v ) ) return v . flatMap ( ( p ) => extractFiles ( p , origin ) ) ; else if ( v instanceof platform_node_js_1 . InputFile ) { const id = randomId ( ) ; Object . assign ( value , { [ k ] : ` ${ id } ` } ) ; return { id , origin , file : v } ; } else return extractFiles ( v , origin ) ; } ) ; }
Replaces all instances of `InputFile` in a given payload by attach:
 strings.
Replaces all instances of ` InputFile ` in a given payload by attach : strings .