From 11cdef07d229dfbb057630f390b8eb35cc882478 Mon Sep 17 00:00:00 2001 From: Elijah Duffy Date: Mon, 11 May 2026 12:41:19 -0700 Subject: [PATCH] clean up go client types Removed unnecessary type re-implementations in favour of using generated types directly and providing aliases for import simplicity. --- clients/go/officeconvertclient/client.go | 88 +++---------------- clients/go/officeconvertclient/orchestrate.go | 5 +- 2 files changed, 14 insertions(+), 79 deletions(-) diff --git a/clients/go/officeconvertclient/client.go b/clients/go/officeconvertclient/client.go index b50def0..a748d58 100644 --- a/clients/go/officeconvertclient/client.go +++ b/clients/go/officeconvertclient/client.go @@ -15,35 +15,20 @@ import ( const defaultPollInterval = 2 * time.Second -// RasterTierOptions defines per-tier raster settings for conversion output. -type RasterTierOptions struct { - Resolution officeconvertapiv1.ConversionResolution - JPEGQuality int32 -} - // HtmlFormattingPolicy configures which formatting features are ignored in HTML notes mode. -type HtmlFormattingPolicy struct { - IgnoreBold bool - IgnoreItalic bool - IgnoreUnderline bool - IgnoreStrikethrough bool - IgnoreFontSize bool - IgnoreColor bool -} +type HtmlFormattingPolicy = officeconvertapiv1.HtmlFormattingPolicy // NotesOptions controls speaker-notes extraction/output. -type NotesOptions struct { - Format officeconvertapiv1.NotesFormat - HTMLUseParagraphTags *bool - HTMLPolicy *HtmlFormattingPolicy -} +type NotesOptions = officeconvertapiv1.NotesOptions -// CreateConversionOptions configures optional full and thumbnail raster tiers. -type CreateConversionOptions struct { - Full *RasterTierOptions - Thumbnail *RasterTierOptions - Notes *NotesOptions -} +// SlideRasterOptions defines rendering settings for a raster output tier. +type SlideRasterOptions = officeconvertapiv1.SlideRasterOptions + +// SlideRaster_JPEG configures JPEG-specific rendering settings. +type SlideRaster_JPEG = officeconvertapiv1.JpegOutputOptions + +// CreateConversionOptions control the behaviour of a CreateConversion session. +type CreateConversionOptions = officeconvertapiv1.CreateConversionRequest // Client wraps the generated Connect client with orchestration-focused helpers. type Client struct { @@ -76,18 +61,9 @@ func (c *Client) SetPollInterval(interval time.Duration) { // CreateConversion starts a conversion session and returns upload metadata. func (c *Client) CreateConversion( ctx context.Context, - sourceFilename string, options *CreateConversionOptions, ) (*CreateConversionResponse, error) { - message := &officeconvertapiv1.CreateConversionRequest{ - SourceFilename: sourceFilename, - } - if options != nil { - message.Full = toProtoSlideRasterOptions(options.Full) - message.Thumbnail = toProtoSlideRasterOptions(options.Thumbnail) - message.Notes = toProtoNotesOptions(options.Notes) - } - req := connect.NewRequest(message) + req := connect.NewRequest(options) res, err := c.rpc.CreateConversion(ctx, req) if err != nil { return nil, err @@ -95,48 +71,6 @@ func (c *Client) CreateConversion( return augmentCreateConversionResponse(res.Msg) } -func toProtoSlideRasterOptions( - options *RasterTierOptions, -) *officeconvertapiv1.SlideRasterOptions { - if options == nil { - return nil - } - proto := &officeconvertapiv1.SlideRasterOptions{ - Resolution: options.Resolution, - } - if options.JPEGQuality != 0 { - proto.Format = &officeconvertapiv1.SlideRasterOptions_Jpeg{ - Jpeg: &officeconvertapiv1.JpegOutputOptions{ - Quality: options.JPEGQuality, - }, - } - } - return proto -} - -func toProtoNotesOptions(options *NotesOptions) *officeconvertapiv1.NotesOptions { - if options == nil { - return nil - } - proto := &officeconvertapiv1.NotesOptions{ - Format: options.Format, - } - if options.HTMLUseParagraphTags != nil { - proto.HtmlUseParagraphTags = options.HTMLUseParagraphTags - } - if options.HTMLPolicy != nil { - proto.HtmlPolicy = &officeconvertapiv1.HtmlFormattingPolicy{ - IgnoreBold: options.HTMLPolicy.IgnoreBold, - IgnoreItalic: options.HTMLPolicy.IgnoreItalic, - IgnoreUnderline: options.HTMLPolicy.IgnoreUnderline, - IgnoreStrikethrough: options.HTMLPolicy.IgnoreStrikethrough, - IgnoreFontSize: options.HTMLPolicy.IgnoreFontSize, - IgnoreColor: options.HTMLPolicy.IgnoreColor, - } - } - return proto -} - // StartConversion signals that upload is complete and conversion can begin. func (c *Client) StartConversion( ctx context.Context, diff --git a/clients/go/officeconvertclient/orchestrate.go b/clients/go/officeconvertclient/orchestrate.go index d705d7e..39d3b9d 100644 --- a/clients/go/officeconvertclient/orchestrate.go +++ b/clients/go/officeconvertclient/orchestrate.go @@ -18,8 +18,9 @@ type ConversionResult struct { func (c *Client) ConvertPPTXFile(ctx context.Context, localPPTXPath string) (*ConversionResult, error) { createRes, err := c.CreateConversion( ctx, - filepath.Base(localPPTXPath), - nil, + &CreateConversionOptions{ + SourceFilename: filepath.Base(localPPTXPath), + }, ) if err != nil { return nil, fmt.Errorf("create conversion: %w", err)