Set IncludeDocResult to true on the envelope in the query handler to guarantee the document result is included in responses. This prevents missing document data when processing envelope queries.
Refactored ReadSingleEnvelopeDocResultQuery to remove inheritance from EnvelopeQueryBase and introduce an Envelope property. Enhanced the handler to ensure DocResult is a non-empty byte array before returning, throwing NotFoundException otherwise.
Refactored ReadSingleEnvelopeDocResultQuery to use a parameterless constructor and an Envelope property. Introduced FinalizeDocumentController with a GET endpoint to finalize and return envelope documents as PDFs, supporting force regeneration. Added dependency injection for IMediator and FinalizeDocumentJob. Includes a TODO to migrate forceRegenerate logic into the job.
Introduced ReadSingleEnvelopeDocResultQuery and its handler to fetch an envelope's document as a byte array via MediatR. Throws NotFoundException if the document is missing. Includes XML documentation for clarity.