-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathsections.ts
More file actions
514 lines (459 loc) · 20.7 KB
/
sections.ts
File metadata and controls
514 lines (459 loc) · 20.7 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
import { DocumentApiValidationError } from '../errors.js';
import { normalizeMutationOptions, type MutationOptions } from '../write/write.js';
import { isRecord } from '../validation-primitives.js';
import type {
DocumentMutationResult,
SectionAddress,
SectionMutationResult,
SectionBreakType,
SectionHeaderFooterKind,
SectionHeaderFooterVariant,
SectionDirection,
SectionOrientation,
SectionPageNumberingChapterSeparator,
SectionVerticalAlign,
SectionsClearHeaderFooterRefInput,
SectionsClearPageBordersInput,
SectionsGetInput,
SectionsListQuery,
SectionsListResult,
SectionsSetBreakTypeInput,
SectionsSetColumnsInput,
SectionsSetHeaderFooterMarginsInput,
SectionsSetHeaderFooterRefInput,
SectionsSetLineNumberingInput,
SectionsSetLinkToPreviousInput,
SectionsSetOddEvenHeadersFootersInput,
SectionsSetPageBordersInput,
SectionsSetPageMarginsInput,
SectionsSetPageNumberingInput,
SectionsSetPageSetupInput,
SectionsSetSectionDirectionInput,
SectionsSetTitlePageInput,
SectionsSetVerticalAlignInput,
SectionInfo,
SectionTargetInput,
} from './sections.types.js';
export type {
DocumentMutationResult,
SectionAddress,
SectionMutationResult,
SectionBreakType,
SectionHeaderFooterKind,
SectionHeaderFooterVariant,
SectionPageNumberingChapterSeparator,
SectionsClearHeaderFooterRefInput,
SectionsClearPageBordersInput,
SectionsGetInput,
SectionsListQuery,
SectionsListResult,
SectionsSetBreakTypeInput,
SectionsSetColumnsInput,
SectionsSetHeaderFooterMarginsInput,
SectionsSetHeaderFooterRefInput,
SectionsSetLineNumberingInput,
SectionsSetLinkToPreviousInput,
SectionsSetOddEvenHeadersFootersInput,
SectionsSetPageBordersInput,
SectionsSetPageMarginsInput,
SectionsSetPageNumberingInput,
SectionsSetPageSetupInput,
SectionsSetSectionDirectionInput,
SectionsSetTitlePageInput,
SectionsSetVerticalAlignInput,
SectionInfo,
SectionTargetInput,
} from './sections.types.js';
const DEFAULT_SECTIONS_LIST_LIMIT = 250;
const SECTION_BREAK_TYPES: readonly SectionBreakType[] = ['continuous', 'nextPage', 'evenPage', 'oddPage'] as const;
const SECTION_ORIENTATIONS: readonly SectionOrientation[] = ['portrait', 'landscape'] as const;
const SECTION_VERTICAL_ALIGNS: readonly SectionVerticalAlign[] = ['top', 'center', 'bottom', 'both'] as const;
const SECTION_DIRECTIONS: readonly SectionDirection[] = ['ltr', 'rtl'] as const;
const HEADER_FOOTER_KINDS: readonly SectionHeaderFooterKind[] = ['header', 'footer'] as const;
const HEADER_FOOTER_VARIANTS: readonly SectionHeaderFooterVariant[] = ['default', 'first', 'even'] as const;
const LINE_NUMBER_RESTARTS = ['continuous', 'newPage', 'newSection'] as const;
const PAGE_NUMBER_FORMATS = [
'decimal',
'lowerLetter',
'upperLetter',
'lowerRoman',
'upperRoman',
'numberInDash',
] as const;
const PAGE_NUMBER_CHAPTER_SEPARATORS: readonly SectionPageNumberingChapterSeparator[] = [
'hyphen',
'period',
'colon',
'emDash',
'enDash',
] as const;
const PAGE_BORDER_DISPLAYS = ['allPages', 'firstPage', 'notFirstPage'] as const;
const PAGE_BORDER_OFFSET_FROM_VALUES = ['page', 'text'] as const;
const PAGE_BORDER_Z_ORDER_VALUES = ['front', 'back'] as const;
function assertSectionAddress(value: unknown, fieldName: string): asserts value is SectionAddress {
if (
!isRecord(value) ||
value.kind !== 'section' ||
typeof value.sectionId !== 'string' ||
value.sectionId.length === 0
) {
throw new DocumentApiValidationError('INVALID_TARGET', `${fieldName} must be a section address.`, {
field: fieldName,
value,
});
}
}
function assertSectionTarget(input: unknown, operationName: string): asserts input is SectionTargetInput {
if (!isRecord(input)) {
throw new DocumentApiValidationError('INVALID_TARGET', `${operationName} input must be an object.`);
}
assertSectionAddress(input.target, `${operationName}.target`);
}
function assertBoolean(value: unknown, fieldName: string): asserts value is boolean {
if (typeof value !== 'boolean') {
throw new DocumentApiValidationError('INVALID_INPUT', `${fieldName} must be a boolean.`, {
field: fieldName,
value,
});
}
}
function assertString(value: unknown, fieldName: string): asserts value is string {
if (typeof value !== 'string') {
throw new DocumentApiValidationError('INVALID_INPUT', `${fieldName} must be a string.`, {
field: fieldName,
value,
});
}
}
function assertNonEmptyString(value: unknown, fieldName: string): asserts value is string {
assertString(value, fieldName);
if (value.trim().length === 0) {
throw new DocumentApiValidationError('INVALID_INPUT', `${fieldName} must be a non-empty string.`, {
field: fieldName,
value,
});
}
}
function assertPositiveInteger(value: unknown, fieldName: string): void {
if (!Number.isInteger(value) || Number(value) <= 0) {
throw new DocumentApiValidationError('INVALID_INPUT', `${fieldName} must be a positive integer.`, {
field: fieldName,
value,
});
}
}
function assertNonNegativeNumber(value: unknown, fieldName: string): void {
if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) {
throw new DocumentApiValidationError('INVALID_INPUT', `${fieldName} must be a non-negative number.`, {
field: fieldName,
value,
});
}
}
function assertOneOf<T extends string>(value: unknown, fieldName: string, allowed: readonly T[]): asserts value is T {
if (typeof value !== 'string' || !(allowed as readonly string[]).includes(value)) {
throw new DocumentApiValidationError('INVALID_INPUT', `${fieldName} must be one of: ${allowed.join(', ')}.`, {
field: fieldName,
value,
allowed,
});
}
}
function hasAnyDefined(value: Record<string, unknown>, keys: readonly string[]): boolean {
return keys.some((key) => value[key] !== undefined);
}
function assertObject(value: unknown, fieldName: string): asserts value is Record<string, unknown> {
if (!isRecord(value)) {
throw new DocumentApiValidationError('INVALID_INPUT', `${fieldName} must be an object.`, {
field: fieldName,
value,
});
}
}
function validateBorderSpec(value: unknown, fieldName: string): void {
assertObject(value, fieldName);
if (!hasAnyDefined(value, ['style', 'size', 'space', 'color', 'shadow', 'frame'])) {
throw new DocumentApiValidationError(
'INVALID_INPUT',
`${fieldName} must include at least one of style, size, space, color, shadow, or frame.`,
{ field: fieldName, value },
);
}
if (value.style !== undefined) assertString(value.style, `${fieldName}.style`);
if (value.size !== undefined) assertNonNegativeNumber(value.size, `${fieldName}.size`);
if (value.space !== undefined) assertNonNegativeNumber(value.space, `${fieldName}.space`);
if (value.color !== undefined) assertString(value.color, `${fieldName}.color`);
if (value.shadow !== undefined) assertBoolean(value.shadow, `${fieldName}.shadow`);
if (value.frame !== undefined) assertBoolean(value.frame, `${fieldName}.frame`);
}
function validatePageBorders(value: unknown, fieldName: string): void {
assertObject(value, fieldName);
if (!hasAnyDefined(value, ['display', 'offsetFrom', 'zOrder', 'top', 'right', 'bottom', 'left'])) {
throw new DocumentApiValidationError('INVALID_INPUT', `${fieldName} requires at least one border field.`, {
field: fieldName,
value,
});
}
if (value.display !== undefined) assertOneOf(value.display, `${fieldName}.display`, PAGE_BORDER_DISPLAYS);
if (value.offsetFrom !== undefined) {
assertOneOf(value.offsetFrom, `${fieldName}.offsetFrom`, PAGE_BORDER_OFFSET_FROM_VALUES);
}
if (value.zOrder !== undefined) assertOneOf(value.zOrder, `${fieldName}.zOrder`, PAGE_BORDER_Z_ORDER_VALUES);
if (value.top !== undefined) validateBorderSpec(value.top, `${fieldName}.top`);
if (value.right !== undefined) validateBorderSpec(value.right, `${fieldName}.right`);
if (value.bottom !== undefined) validateBorderSpec(value.bottom, `${fieldName}.bottom`);
if (value.left !== undefined) validateBorderSpec(value.left, `${fieldName}.left`);
}
function normalizeSectionsListQuery(query?: SectionsListQuery): Required<SectionsListQuery> {
const limit = query?.limit ?? DEFAULT_SECTIONS_LIST_LIMIT;
const offset = query?.offset ?? 0;
if (!Number.isInteger(limit) || Number(limit) <= 0) {
throw new DocumentApiValidationError('INVALID_INPUT', 'sections.list limit must be a positive integer.', {
field: 'limit',
value: limit,
});
}
if (!Number.isInteger(offset) || Number(offset) < 0) {
throw new DocumentApiValidationError('INVALID_INPUT', 'sections.list offset must be a non-negative integer.', {
field: 'offset',
value: offset,
});
}
return { limit: Number(limit), offset: Number(offset) };
}
function validateHeaderFooterRefParams(
operationName: string,
kind: unknown,
variant: unknown,
): asserts kind is SectionHeaderFooterKind & string {
assertOneOf(kind, `${operationName}.kind`, HEADER_FOOTER_KINDS);
assertOneOf(variant, `${operationName}.variant`, HEADER_FOOTER_VARIANTS);
}
export interface SectionsAdapter {
list(query?: SectionsListQuery): SectionsListResult;
get(input: SectionsGetInput): SectionInfo;
setBreakType(input: SectionsSetBreakTypeInput, options?: MutationOptions): SectionMutationResult;
setPageMargins(input: SectionsSetPageMarginsInput, options?: MutationOptions): SectionMutationResult;
setHeaderFooterMargins(input: SectionsSetHeaderFooterMarginsInput, options?: MutationOptions): SectionMutationResult;
setPageSetup(input: SectionsSetPageSetupInput, options?: MutationOptions): SectionMutationResult;
setColumns(input: SectionsSetColumnsInput, options?: MutationOptions): SectionMutationResult;
setLineNumbering(input: SectionsSetLineNumberingInput, options?: MutationOptions): SectionMutationResult;
setPageNumbering(input: SectionsSetPageNumberingInput, options?: MutationOptions): SectionMutationResult;
setTitlePage(input: SectionsSetTitlePageInput, options?: MutationOptions): SectionMutationResult;
setOddEvenHeadersFooters(
input: SectionsSetOddEvenHeadersFootersInput,
options?: MutationOptions,
): DocumentMutationResult;
setVerticalAlign(input: SectionsSetVerticalAlignInput, options?: MutationOptions): SectionMutationResult;
setSectionDirection(input: SectionsSetSectionDirectionInput, options?: MutationOptions): SectionMutationResult;
setHeaderFooterRef(input: SectionsSetHeaderFooterRefInput, options?: MutationOptions): SectionMutationResult;
clearHeaderFooterRef(input: SectionsClearHeaderFooterRefInput, options?: MutationOptions): SectionMutationResult;
setLinkToPrevious(input: SectionsSetLinkToPreviousInput, options?: MutationOptions): SectionMutationResult;
setPageBorders(input: SectionsSetPageBordersInput, options?: MutationOptions): SectionMutationResult;
clearPageBorders(input: SectionsClearPageBordersInput, options?: MutationOptions): SectionMutationResult;
}
export type SectionsApi = SectionsAdapter;
export function executeSectionsList(adapter: SectionsAdapter, query?: SectionsListQuery): SectionsListResult {
return adapter.list(normalizeSectionsListQuery(query));
}
export function executeSectionsGet(adapter: SectionsAdapter, input: SectionsGetInput): SectionInfo {
assertSectionAddress(input?.address, 'sections.get.address');
return adapter.get(input);
}
export function executeSectionsSetBreakType(
adapter: SectionsAdapter,
input: SectionsSetBreakTypeInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setBreakType');
assertOneOf(input.breakType, 'sections.setBreakType.breakType', SECTION_BREAK_TYPES);
return adapter.setBreakType(input, normalizeMutationOptions(options));
}
export function executeSectionsSetPageMargins(
adapter: SectionsAdapter,
input: SectionsSetPageMarginsInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setPageMargins');
if (!hasAnyDefined(input as unknown as Record<string, unknown>, ['top', 'right', 'bottom', 'left', 'gutter'])) {
throw new DocumentApiValidationError(
'INVALID_INPUT',
'sections.setPageMargins requires at least one margin field.',
);
}
if (input.top !== undefined) assertNonNegativeNumber(input.top, 'sections.setPageMargins.top');
if (input.right !== undefined) assertNonNegativeNumber(input.right, 'sections.setPageMargins.right');
if (input.bottom !== undefined) assertNonNegativeNumber(input.bottom, 'sections.setPageMargins.bottom');
if (input.left !== undefined) assertNonNegativeNumber(input.left, 'sections.setPageMargins.left');
if (input.gutter !== undefined) assertNonNegativeNumber(input.gutter, 'sections.setPageMargins.gutter');
return adapter.setPageMargins(input, normalizeMutationOptions(options));
}
export function executeSectionsSetHeaderFooterMargins(
adapter: SectionsAdapter,
input: SectionsSetHeaderFooterMarginsInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setHeaderFooterMargins');
if (!hasAnyDefined(input as unknown as Record<string, unknown>, ['header', 'footer'])) {
throw new DocumentApiValidationError(
'INVALID_INPUT',
'sections.setHeaderFooterMargins requires at least one margin field.',
);
}
if (input.header !== undefined) assertNonNegativeNumber(input.header, 'sections.setHeaderFooterMargins.header');
if (input.footer !== undefined) assertNonNegativeNumber(input.footer, 'sections.setHeaderFooterMargins.footer');
return adapter.setHeaderFooterMargins(input, normalizeMutationOptions(options));
}
export function executeSectionsSetPageSetup(
adapter: SectionsAdapter,
input: SectionsSetPageSetupInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setPageSetup');
if (!hasAnyDefined(input as unknown as Record<string, unknown>, ['width', 'height', 'orientation', 'paperSize'])) {
throw new DocumentApiValidationError('INVALID_INPUT', 'sections.setPageSetup requires at least one setup field.');
}
if (input.width !== undefined) assertNonNegativeNumber(input.width, 'sections.setPageSetup.width');
if (input.height !== undefined) assertNonNegativeNumber(input.height, 'sections.setPageSetup.height');
if (input.orientation !== undefined) {
assertOneOf(input.orientation, 'sections.setPageSetup.orientation', SECTION_ORIENTATIONS);
}
if (input.paperSize !== undefined) assertNonEmptyString(input.paperSize, 'sections.setPageSetup.paperSize');
return adapter.setPageSetup(input, normalizeMutationOptions(options));
}
export function executeSectionsSetColumns(
adapter: SectionsAdapter,
input: SectionsSetColumnsInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setColumns');
if (!hasAnyDefined(input as unknown as Record<string, unknown>, ['count', 'gap', 'equalWidth'])) {
throw new DocumentApiValidationError('INVALID_INPUT', 'sections.setColumns requires at least one columns field.');
}
if (input.count !== undefined) assertPositiveInteger(input.count, 'sections.setColumns.count');
if (input.gap !== undefined) assertNonNegativeNumber(input.gap, 'sections.setColumns.gap');
if (input.equalWidth !== undefined) assertBoolean(input.equalWidth, 'sections.setColumns.equalWidth');
return adapter.setColumns(input, normalizeMutationOptions(options));
}
export function executeSectionsSetLineNumbering(
adapter: SectionsAdapter,
input: SectionsSetLineNumberingInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setLineNumbering');
assertBoolean(input.enabled, 'sections.setLineNumbering.enabled');
if (input.countBy !== undefined) assertPositiveInteger(input.countBy, 'sections.setLineNumbering.countBy');
if (input.start !== undefined) assertPositiveInteger(input.start, 'sections.setLineNumbering.start');
if (input.distance !== undefined) assertNonNegativeNumber(input.distance, 'sections.setLineNumbering.distance');
if (input.restart !== undefined) {
assertOneOf(input.restart, 'sections.setLineNumbering.restart', LINE_NUMBER_RESTARTS);
}
return adapter.setLineNumbering(input, normalizeMutationOptions(options));
}
export function executeSectionsSetPageNumbering(
adapter: SectionsAdapter,
input: SectionsSetPageNumberingInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setPageNumbering');
if (
!hasAnyDefined(input as unknown as Record<string, unknown>, ['start', 'format', 'chapterStyle', 'chapterSeparator'])
) {
throw new DocumentApiValidationError(
'INVALID_INPUT',
'sections.setPageNumbering requires at least one of start, format, chapterStyle, or chapterSeparator.',
);
}
if (input.start !== undefined) assertPositiveInteger(input.start, 'sections.setPageNumbering.start');
if (input.format !== undefined) {
assertOneOf(input.format, 'sections.setPageNumbering.format', PAGE_NUMBER_FORMATS);
}
if (input.chapterStyle !== undefined) {
assertPositiveInteger(input.chapterStyle, 'sections.setPageNumbering.chapterStyle');
}
if (input.chapterSeparator !== undefined) {
assertOneOf(input.chapterSeparator, 'sections.setPageNumbering.chapterSeparator', PAGE_NUMBER_CHAPTER_SEPARATORS);
}
return adapter.setPageNumbering(input, normalizeMutationOptions(options));
}
export function executeSectionsSetTitlePage(
adapter: SectionsAdapter,
input: SectionsSetTitlePageInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setTitlePage');
assertBoolean(input.enabled, 'sections.setTitlePage.enabled');
return adapter.setTitlePage(input, normalizeMutationOptions(options));
}
export function executeSectionsSetOddEvenHeadersFooters(
adapter: SectionsAdapter,
input: SectionsSetOddEvenHeadersFootersInput,
options?: MutationOptions,
): DocumentMutationResult {
assertBoolean(input?.enabled, 'sections.setOddEvenHeadersFooters.enabled');
return adapter.setOddEvenHeadersFooters(input, normalizeMutationOptions(options));
}
export function executeSectionsSetVerticalAlign(
adapter: SectionsAdapter,
input: SectionsSetVerticalAlignInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setVerticalAlign');
assertOneOf(input.value, 'sections.setVerticalAlign.value', SECTION_VERTICAL_ALIGNS);
return adapter.setVerticalAlign(input, normalizeMutationOptions(options));
}
export function executeSectionsSetSectionDirection(
adapter: SectionsAdapter,
input: SectionsSetSectionDirectionInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setSectionDirection');
assertOneOf(input.direction, 'sections.setSectionDirection.direction', SECTION_DIRECTIONS);
return adapter.setSectionDirection(input, normalizeMutationOptions(options));
}
export function executeSectionsSetHeaderFooterRef(
adapter: SectionsAdapter,
input: SectionsSetHeaderFooterRefInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setHeaderFooterRef');
validateHeaderFooterRefParams('sections.setHeaderFooterRef', input.kind, input.variant);
assertNonEmptyString(input.refId, 'sections.setHeaderFooterRef.refId');
return adapter.setHeaderFooterRef(input, normalizeMutationOptions(options));
}
export function executeSectionsClearHeaderFooterRef(
adapter: SectionsAdapter,
input: SectionsClearHeaderFooterRefInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.clearHeaderFooterRef');
validateHeaderFooterRefParams('sections.clearHeaderFooterRef', input.kind, input.variant);
return adapter.clearHeaderFooterRef(input, normalizeMutationOptions(options));
}
export function executeSectionsSetLinkToPrevious(
adapter: SectionsAdapter,
input: SectionsSetLinkToPreviousInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setLinkToPrevious');
validateHeaderFooterRefParams('sections.setLinkToPrevious', input.kind, input.variant);
assertBoolean(input.linked, 'sections.setLinkToPrevious.linked');
return adapter.setLinkToPrevious(input, normalizeMutationOptions(options));
}
export function executeSectionsSetPageBorders(
adapter: SectionsAdapter,
input: SectionsSetPageBordersInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.setPageBorders');
validatePageBorders(input.borders, 'sections.setPageBorders.borders');
return adapter.setPageBorders(input, normalizeMutationOptions(options));
}
export function executeSectionsClearPageBorders(
adapter: SectionsAdapter,
input: SectionsClearPageBordersInput,
options?: MutationOptions,
): SectionMutationResult {
assertSectionTarget(input, 'sections.clearPageBorders');
return adapter.clearPageBorders(input, normalizeMutationOptions(options));
}