-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes_options.go
More file actions
241 lines (213 loc) · 8.61 KB
/
types_options.go
File metadata and controls
241 lines (213 loc) · 8.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
package cloudlayer
// Margin represents page margins with CSS units or pixel values.
type Margin struct {
Top *LayoutDimension `json:"top,omitempty"`
Right *LayoutDimension `json:"right,omitempty"`
Bottom *LayoutDimension `json:"bottom,omitempty"`
Left *LayoutDimension `json:"left,omitempty"`
}
// Viewport represents a browser viewport configuration.
// Note: the JSON field name is "viewPort" (capital P) to match the legacy API.
type Viewport struct {
Width int `json:"width"`
Height int `json:"height"`
DeviceScaleFactor float64 `json:"deviceScaleFactor,omitempty"`
IsMobile bool `json:"isMobile,omitempty"`
HasTouch bool `json:"hasTouch,omitempty"`
IsLandscape bool `json:"isLandscape,omitempty"`
}
// Cookie represents a browser cookie to set before page navigation.
type Cookie struct {
Name string `json:"name"`
Value string `json:"value"`
URL *string `json:"url,omitempty"`
Domain *string `json:"domain,omitempty"`
Path *string `json:"path,omitempty"`
Expires *int `json:"expires,omitempty"`
HTTPOnly *bool `json:"httpOnly,omitempty"`
Secure *bool `json:"secure,omitempty"`
SameSite *string `json:"sameSite,omitempty"`
}
// Authentication represents HTTP basic authentication credentials.
type Authentication struct {
Username string `json:"username"`
Password string `json:"password"`
}
// Batch represents a batch of URLs for batch conversion.
type Batch struct {
URLs []string `json:"urls"`
}
// HeaderFooterTemplate configures a PDF header or footer.
type HeaderFooterTemplate struct {
Method *string `json:"method,omitempty"`
Selector *string `json:"selector,omitempty"`
Margin *Margin `json:"margin,omitempty"`
Style map[string]string `json:"style,omitempty"`
ImageStyle map[string]string `json:"imageStyle,omitempty"`
Template *string `json:"template,omitempty"`
TemplateString *string `json:"templateString,omitempty"`
}
// PreviewOptions configures preview image generation for a conversion.
type PreviewOptions struct {
Width *int `json:"width,omitempty"`
Height *int `json:"height,omitempty"`
Type *ImageType `json:"type,omitempty"`
Quality int `json:"quality"`
MaintainAspectRatio *bool `json:"maintainAspectRatio,omitempty"`
}
// WaitForSelectorOptions configures waiting for a DOM selector.
type WaitForSelectorOptions struct {
Selector string `json:"selector"`
Options *WaitForSelectorSubOptions `json:"options,omitempty"`
}
// WaitForSelectorSubOptions are additional options for WaitForSelector.
type WaitForSelectorSubOptions struct {
Visible *bool `json:"visible,omitempty"`
Hidden *bool `json:"hidden,omitempty"`
Timeout *int `json:"timeout,omitempty"`
}
// PDFOptions configures PDF-specific output settings.
type PDFOptions struct {
PrintBackground *bool `json:"printBackground,omitempty"`
Format *PDFFormat `json:"format,omitempty"`
Margin *Margin `json:"margin,omitempty"`
HeaderTemplate *HeaderFooterTemplate `json:"headerTemplate,omitempty"`
FooterTemplate *HeaderFooterTemplate `json:"footerTemplate,omitempty"`
GeneratePreview *GeneratePreviewOption `json:"generatePreview,omitempty"`
}
// ImageOptions configures image-specific output settings.
type ImageOptions struct {
ImageType *ImageType `json:"imageType,omitempty"`
Quality *int `json:"quality,omitempty"`
Trim *bool `json:"trim,omitempty"`
Transparent *bool `json:"transparent,omitempty"`
GeneratePreview *GeneratePreviewOption `json:"generatePreview,omitempty"`
}
// PuppeteerOptions configures browser rendering behavior.
type PuppeteerOptions struct {
WaitUntil *WaitUntil `json:"waitUntil,omitempty"`
WaitForFrame *bool `json:"waitForFrame,omitempty"`
WaitForFrameAttachment *bool `json:"waitForFrameAttachment,omitempty"`
WaitForFrameNavigation *WaitUntil `json:"waitForFrameNavigation,omitempty"`
WaitForFrameImages *bool `json:"waitForFrameImages,omitempty"`
WaitForFrameSelector *WaitForSelectorOptions `json:"waitForFrameSelector,omitempty"`
WaitForSelector *WaitForSelectorOptions `json:"waitForSelector,omitempty"`
PreferCSSPageSize *bool `json:"preferCSSPageSize,omitempty"`
Scale *float64 `json:"scale,omitempty"`
Height *LayoutDimension `json:"height,omitempty"`
Width *LayoutDimension `json:"width,omitempty"`
Landscape *bool `json:"landscape,omitempty"`
PageRanges *string `json:"pageRanges,omitempty"`
AutoScroll *bool `json:"autoScroll,omitempty"`
ViewPort *Viewport `json:"viewPort,omitempty"`
TimeZone *string `json:"timeZone,omitempty"`
EmulateMediaType *NullableString `json:"emulateMediaType,omitempty"`
}
// URLOptions configures URL-based conversion input.
type URLOptions struct {
URL *string `json:"url,omitempty"`
Authentication *Authentication `json:"authentication,omitempty"`
Batch *Batch `json:"batch,omitempty"`
Cookies []Cookie `json:"cookies,omitempty"`
}
// HTMLOptions configures HTML-based conversion input.
type HTMLOptions struct {
// HTML is the base64-encoded HTML content. Required.
// Use [EncodeHTML] to encode raw HTML strings.
HTML string `json:"html"`
}
// TemplateOptions configures template-based conversion input.
// Note: the "name" field is provided by [BaseOptions] which is always
// embedded alongside TemplateOptions in composite types.
type TemplateOptions struct {
TemplateID *string `json:"templateId,omitempty"`
Template *string `json:"template,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
}
// BaseOptions are common options shared by all conversion endpoints.
type BaseOptions struct {
Name *string `json:"name,omitempty"`
Timeout *int `json:"timeout,omitempty"`
Delay *int `json:"delay,omitempty"`
Filename *string `json:"filename,omitempty"`
Inline *bool `json:"inline,omitempty"`
Async *bool `json:"async,omitempty"`
Storage *StorageOption `json:"storage,omitempty"`
Webhook *string `json:"webhook,omitempty"`
APIVer *string `json:"apiVer,omitempty"`
ProjectID *string `json:"projectId,omitempty"`
}
// StorageRequestOptions identifies a specific storage configuration by ID.
type StorageRequestOptions struct {
ID string `json:"id"`
}
// URLToPDFOptions are options for [Client.URLToPDF].
type URLToPDFOptions struct {
URLOptions
PDFOptions
PuppeteerOptions
BaseOptions
}
// URLToImageOptions are options for [Client.URLToImage].
type URLToImageOptions struct {
URLOptions
ImageOptions
PuppeteerOptions
BaseOptions
}
// HTMLToPDFOptions are options for [Client.HTMLToPDF].
type HTMLToPDFOptions struct {
HTMLOptions
PDFOptions
PuppeteerOptions
BaseOptions
}
// HTMLToImageOptions are options for [Client.HTMLToImage].
type HTMLToImageOptions struct {
HTMLOptions
ImageOptions
PuppeteerOptions
BaseOptions
}
// TemplateToPDFOptions are options for [Client.TemplateToPDF].
type TemplateToPDFOptions struct {
TemplateOptions
PDFOptions
PuppeteerOptions
BaseOptions
}
// TemplateToImageOptions are options for [Client.TemplateToImage].
type TemplateToImageOptions struct {
TemplateOptions
ImageOptions
PuppeteerOptions
BaseOptions
}
// DOCXToPDFOptions are options for [Client.DOCXToPDF].
type DOCXToPDFOptions struct {
File *FileInput `json:"-"`
BaseOptions
}
// DOCXToHTMLOptions are options for [Client.DOCXToHTML].
type DOCXToHTMLOptions struct {
File *FileInput `json:"-"`
BaseOptions
}
// PDFToDOCXOptions are options for [Client.PDFToDOCX].
type PDFToDOCXOptions struct {
File *FileInput `json:"-"`
BaseOptions
}
// MergePDFsOptions are options for [Client.MergePDFs].
// Merge uses URL-based input, not file uploads.
type MergePDFsOptions struct {
URLOptions
BaseOptions
}
// ListTemplatesOptions are optional query parameters for [Client.ListTemplates].
type ListTemplatesOptions struct {
Type *string `json:"type,omitempty"`
Category *string `json:"category,omitempty"`
Tags *string `json:"tags,omitempty"`
Expand *bool `json:"expand,omitempty"`
}